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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user