You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently upgraded dockerpy version to 6.2, and we found out an issue when we try to make a call to a non-existent API.
Before this upgrade, we used to get docker.errors.NotFound error with following details;
Traceback (most recent call last):
File "test.py", line 9, in <module>
main()
File "test.py", line 5, in main
registry_data = docker_client.images.get_registry_data("docker/hello-world")
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/models/images.py", line 337, in get_registry_data
attrs=self.client.api.inspect_distribution(name, auth_config),
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/utils/decorators.py", line 34, in wrapper
return f(self, *args, **kwargs)
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/api/image.py", line 281, in inspect_distribution
return self._result(
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/api/client.py", line 267, in _result
self._raise_for_status(response)
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/api/client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/private/tmp/docker-test/.venv420/lib/python3.8/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.NotFound: 404 Client Error: Not Found ("b'Not Found'")
After upgrade, we are now getting this error Error: a bytes-like object is required, not 'str', which is raised during error handling/generation inside dockerpy library;
Traceback (most recent call last):
File "test.py", line 9, in <module>
main()
File "test.py", line 5, in main
registry_data = docker_client.images.get_registry_data("docker/hello-world")
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/models/images.py", line 356, in get_registry_data
attrs=self.client.api.inspect_distribution(name, auth_config),
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/utils/decorators.py", line 34, in wrapper
return f(self, *args, **kwargs)
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/api/image.py", line 287, in inspect_distribution
return self._result(
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/api/client.py", line 274, in _result
self._raise_for_status(response)
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/api/client.py", line 270, in _raise_for_status
raise create_api_error_from_http_exception(e) from e
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/errors.py", line 34, in create_api_error_from_http_exception
if any(fragment in explanation_msg
File "/private/tmp/docker-test/.venv610/lib/python3.8/site-packages/docker/errors.py", line 34, in <genexpr>
if any(fragment in explanation_msg
Error: a bytes-like object is required, not 'str'
I think error originates from here https://github.com/docker/docker-py/blob/main/docker/errors.py#L30, since response.content was a string type before, now it is bytes. In order to fix the issue, you might need to change that line to response.text so that it will return a string.
Happy to raise a PR if you are willing to review it.
Thanks!
The text was updated successfully, but these errors were encountered:
Main goal here is to upgrade to docker-py==7.0.0 which contains a bugfix that I ran into while testing locally with Python 3.12:
docker/docker-py#3151
Looks like the bug was introduced in version 6.1.2 which we bumped to in #194 but did not release yet so no users should be affected.
This commit also include remove the duplicate CI job `pre-commit`, since we already use `pre-commit.ci` hook.
Hi there,
We recently upgraded dockerpy version to 6.2, and we found out an issue when we try to make a call to a non-existent API.
Before this upgrade, we used to get
docker.errors.NotFound
error with following details;After upgrade, we are now getting this error
Error: a bytes-like object is required, not 'str'
, which is raised during error handling/generation inside dockerpy library;I think error originates from here https://github.com/docker/docker-py/blob/main/docker/errors.py#L30, since
response.content
was a string type before, now it is bytes. In order to fix the issue, you might need to change that line toresponse.text
so that it will return a string.Happy to raise a PR if you are willing to review it.
Thanks!
The text was updated successfully, but these errors were encountered: