Fix delete_image: use sha256 image ID instead of name+tag
DSM SYNO.Docker.Image/delete returns error 114 when called with name+tag.
The API expects the sha256 hash from the image list (field "id") as the
"id" parameter.
- Look up the sha256 hash from SYNO.Docker.Image/list (already fetched
for the in-use check), then pass params={"id": img_hash}
- Guard against missing hash with a clear error message
- Updated tests to assert id param is sent, name/tag are absent
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -243,20 +243,17 @@ def register_images(mcp: FastMCP, config: AppConfig, client: DsmClient) -> None:
|
||||
f"Call delete_image(image_id={image_id!r}, confirmed=True) to confirm."
|
||||
)
|
||||
|
||||
# Perform deletion using the resolved name+tag.
|
||||
# N4S4 reference: SYNO.Docker.Image / delete, params: name, tag
|
||||
delete_name = repo
|
||||
delete_tag = img_tags[0] if img_tags else tag
|
||||
sys.stderr.write(
|
||||
f"[delete_image] api=SYNO.Docker.Image method=delete"
|
||||
f" name={delete_name!r} tag={delete_tag!r}\n"
|
||||
)
|
||||
# DSM requires the sha256 image ID for deletion, not name+tag.
|
||||
if not img_hash:
|
||||
return f"Cannot delete '{display_name}': image ID (sha256) not found in list."
|
||||
|
||||
sys.stderr.write(f"[delete_image] api=SYNO.Docker.Image method=delete id={img_hash!r}\n")
|
||||
sys.stderr.flush()
|
||||
try:
|
||||
await client.request(
|
||||
"SYNO.Docker.Image",
|
||||
"delete",
|
||||
params={"name": delete_name, "tag": delete_tag},
|
||||
params={"id": img_hash},
|
||||
)
|
||||
except Exception as e:
|
||||
code = getattr(e, "code", "?")
|
||||
|
||||
Reference in New Issue
Block a user