From 54cfcef6e2cd5353ec3ab2bf6e80cb2515e1f8aa Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Fri, 6 Nov 2026 14:31:26 +0800 Subject: [PATCH] fix: send the docker force query parameter as a string The aiohttp URL builder only accepts strings, ints and floats as query values and raises a TypeError on a Python bool, so deleting an image answered a 500. Send true/false like the controller does. --- gns3server/compute/docker/__init__.py | 2 +- tests/compute/docker/test_docker.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gns3server/compute/docker/__init__.py b/gns3server/compute/docker/__init__.py index 588ce63fc..f71141ab3 100644 --- a/gns3server/compute/docker/__init__.py +++ b/gns3server/compute/docker/__init__.py @@ -544,7 +544,7 @@ class Docker(BaseManager): :param force: Remove the image even if a container uses it """ - await self.query("DELETE", f"images/{image}", params={"force": force}) + await self.query("DELETE", f"images/{image}", params={"force": str(force).lower()}) # the image id translation recorded when this image was synced from the # controller no longer matches anything on this daemon self._image_id_translations.pop(image, None) diff --git a/tests/compute/docker/test_docker.py b/tests/compute/docker/test_docker.py index ef031ce6b..8699d6337 100644 --- a/tests/compute/docker/test_docker.py +++ b/tests/compute/docker/test_docker.py @@ -341,7 +341,9 @@ async def test_delete_image(): with asyncio_patch("gns3server.compute.docker.Docker.query") as mock: await docker.delete_image("ubuntu:latest", force=True) - mock.assert_called_with("DELETE", "images/ubuntu:latest", params={"force": True}) + # the daemon query string only accepts strings, ints and floats: a + # Python bool would make the aiohttp URL builder raise a TypeError + mock.assert_called_with("DELETE", "images/ubuntu:latest", params={"force": "true"}) # deleting the image drops the id translation recorded for a previous sync assert docker.image_id_translation("ubuntu:latest") is None