Skip to content

Commit b649df3

Browse files
committed
Don't try to parse the response json when not_modified
In case of not_modified (HTTP 304), there is no json in the response body. Json parsing fails like: ```python if response.status_code == requests.codes.not_modified: if kwargs.get("ignore", False): return body = response > raise APIError(body["cause"], response=response, explanation=body) E TypeError: 'APIResponse' object is not subscriptable .venv/lib/python3.12/site-packages/podman/domain/containers.py:477: TypeError ``` This patch fixes this in the way that APIError is rised with content from the text of the requests response Signed-off-by: Jaroslav Henner <[email protected]>
1 parent 5499b17 commit b649df3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

podman/domain/containers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ def stop(self, **kwargs) -> None:
472472
if response.status_code == requests.codes.not_modified:
473473
if kwargs.get("ignore", False):
474474
return
475+
else:
476+
raise APIError(
477+
response.text, response=response, explanation="Container already stopped."
478+
)
475479

476480
body = response.json()
477481
raise APIError(body["cause"], response=response, explanation=body["message"])

0 commit comments

Comments
 (0)