Build API doesn't accept Path Like objects
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Traceback (most recent call last):
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/api/client.py", line 229, in _raise_for_status
response.raise_for_status()
File "/home/batuhan/.local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.35/images/evality/json
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "evality.py", line 12, in obtain_image
return self._docker_client.images.get('evality')
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/models/images.py", line 295, in get
return self.prepare_model(self.client.api.inspect_image(name))
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/api/image.py", line 245, in inspect_image
self._get(self._url("/images/{0}/json", image)), True
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/api/client.py", line 235, in _result
self._raise_for_status(response)
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/api/client.py", line 231, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error: Not Found ("no such image: evality: No such image: evality:latest")
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "evality.py", line 21, in <module>
evality = Evality(docker_client, api_client)
File "evality.py", line 8, in __init__
self._image = self.obtain_image()
File "evality.py", line 15, in obtain_image
path = Path(__file__).parent
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/models/images.py", line 258, in build
resp = self.client.api.build(**kwargs)
File "/home/batuhan/.local/lib/python3.7/site-packages/docker/api/build.py", line 138, in build
elif path.startswith(('http://', 'https://',
AttributeError: 'PosixPath' object has no attribute 'startswith'
return self._docker_client.images.build(path = Path(__file__).parent)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in docker/api/build.py at the build method's path handling, using the reported images.build(path=Path(file).parent) call as the reproduction. Confirm that a pathlib Path is accepted alongside the existing path inputs, then verify the build API no longer raises AttributeError for this call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100