Page MenuHomeSoftware Heritage

golang: /@latest sometimes returns an empty body
Closed, MigratedEdits Locked

Description

with a 200 status code, instead of a 404 error; which makes get_default_version crash with:

https://sentry.softwareheritage.org/organizations/swh/issues/105676/?referrer=phabricator_plugin

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
(2 additional frame(s) were not displayed)
...
  File "swh/loader/package/utils.py", line 209, in newf
    value = f(self)
  File "swh/loader/package/golang/loader.py", line 73, in get_default_version
    return json.loads(latest)["Version"]
  File "__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

Failed to get list of versions for https://pkg.go.dev/gitee.com/lyt_sichuan/pulsar-client-go.git

We should report this to pkg.go.dev, and maybe add a workaround on our side (if latest == "": raise NotFound(...))