Skip to content

Can kaboom with non-informative JSONDecodeError #223

@yarikoptic

Description

@yarikoptic
❯ uv run try_oras.py
Traceback (most recent call last):
  File "/home/yoh/proj/datalad/trash/.venv/lib/python3.11/site-packages/requests/models.py", line 976, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yoh/.local/share/uv/python/cpython-3.11.12-linux-x86_64-gnu/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yoh/.local/share/uv/python/cpython-3.11.12-linux-x86_64-gnu/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yoh/.local/share/uv/python/cpython-3.11.12-linux-x86_64-gnu/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/yoh/proj/datalad/trash/try_oras.py", line 6, in <module>
    client.get_manifest(container)
  File "/home/yoh/proj/misc/oras-py/oras/decorator.py", line 26, in wrapper
    return func(cls, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yoh/proj/misc/oras-py/oras/provider.py", line 961, in get_manifest
    manifest = response.json()
               ^^^^^^^^^^^^^^^
  File "/home/yoh/proj/datalad/trash/.venv/lib/python3.11/site-packages/requests/models.py", line 980, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

on a trivial script

import oras.client
from oras.container import Container

client = oras.client.OrasClient()
container = Container("neurodebian:sid")
client.get_manifest(container)

since receiving HTML

957  	        get_manifest = f"{self.prefix}://{container.manifest_url()}"  # type: ignore
958  	        response = self.do_request(get_manifest, "GET", headers=headers)
959  	
960  	        self._check_200_response(response)
961  ->	        manifest = response.json()
962  	        jsonschema.validate(manifest, schema=oras.schemas.manifest)
963  	        return manifest
964  	
965  	    @decorator.retry()
966  	    def do_request(
(Pdb) p get_manifest
'https://docker.io/v2/neurodebian/manifests/sid'
(Pdb) p headers
{'Accept': 'application/vnd.oci.image.manifest.v1+json'}
(Pdb) p response.text[:10]
'<!DOCTYPE '

but is such a url legit/desired for manifest??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions