Skip to content

Requests fail for mirror.gcr.io #38

@MShekow

Description

@MShekow

To reproduce:

img = ImageName.parse("mirror.gcr.io/hashicorp/terraform:latest")
async with DockerRegistryClientAsync() as registry_client:
    test = await registry_client.head_manifest(img)  # raises KeyError: 'service'

Stack trace:

  File "/home/marius/code/docker-tag-monitor/update_database.py", line 355, in <module>
    asyncio.run(main())
python-BaseException
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/update_database.py", line 290, in main
    test = await registry_client.head_manifest(img)  # raises ContentTypeError
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/.venv/lib/python3.12/site-packages/docker_registry_client_async/dockerregistryclientasync.py", line 1314, in head_manifest
    client_response = await self._head_manifest(image_name, accept=accept, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/.venv/lib/python3.12/site-packages/docker_registry_client_async/dockerregistryclientasync.py", line 1274, in _head_manifest
    headers = await self._get_request_headers(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/.venv/lib/python3.12/site-packages/docker_registry_client_async/dockerregistryclientasync.py", line 396, in _get_request_headers
    token = await self._get_token(
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/.venv/lib/python3.12/site-packages/docker_registry_client_async/dockerregistryclientasync.py", line 467, in _get_token
    token = await self._get_auth_token(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marius/code/docker-tag-monitor/.venv/lib/python3.12/site-packages/docker_registry_client_async/dockerregistryclientasync.py", line 282, in _get_auth_token
    bearer["realm"], bearer["service"], scope
                     ~~~~~~^^^^^^^^^^^
KeyError: 'service'

Tested with DRCA version 1.0.2.

I think GCR does the authentication differently than your code expects it to.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions