Fix delete_image: use rpartition for name:tag splitting

partition(":") split at the first colon, so registry-prefixed images
like "ghcr.io/open-webui/open-webui:v0.8.10" produced name="ghcr"
instead of the correct repository name, causing DSM error 114.

rpartition(":") always splits at the last colon, correctly handling:
- plain images: "nginx:1.24" → name="nginx", tag="1.24"
- namespaced: "nouchka/sqlite3:latest" → correct split
- registry URLs: "ghcr.io/foo/bar:v1" → name="ghcr.io/foo/bar", tag="v1"
- no tag: "nginx" → name="nginx", tag="latest" (fallback)

Added regression test verifying correct params sent to DSM delete API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 17:51:02 +02:00
parent 06735bb447
commit 24c3059e83
2 changed files with 53 additions and 3 deletions
+7 -3
View File
@@ -166,9 +166,13 @@ def register_images(mcp: FastMCP, config: AppConfig, client: DsmClient) -> None:
confirmed: Must be True to actually delete. Default False shows
a preview only.
"""
# Parse name:tag
name, _, tag = image_id.partition(":")
if not tag:
# Parse name and tag using the last ":" as separator so that
# registry-prefixed images (e.g. "ghcr.io/foo/bar:v1") are handled
# correctly. rpartition returns ("", "", original) when ":" is absent.
name, sep, tag = image_id.rpartition(":")
if not sep:
# No ":" found — bare name without explicit tag
name = image_id
tag = "latest"
# Fetch the local image list for size reporting and in-use detection