Skip to content

Omit unset values from Docker SDK filters - #59

Open
X1pheR wants to merge 1 commit into
ckreiling:mainfrom
X1pheR:fix/docker-filter-none-values
Open

Omit unset values from Docker SDK filters#59
X1pheR wants to merge 1 commit into
ckreiling:mainfrom
X1pheR:fix/docker-filter-none-values

Conversation

@X1pheR

@X1pheR X1pheR commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Omit unset optional fields when converting typed MCP filter models into Docker SDK filter dictionaries.

Problem

ListImagesFilters(dangling=True) currently becomes {"dangling": true, "label": null}. With Docker SDK 7.1.0 against a live daemon, that changes the result from the expected dangling-image set to an empty result.

Observed against the same daemon:

  • {"dangling": true} -> 29 images
  • {"dangling": true, "label": null} -> 0 images
  • {"dangling": true, "label": []} -> 29 images

The same issue can affect the optional label fields on container and network filters.

Change

Add one small _docker_filters() normalization boundary using model_dump(exclude_none=True) and use it for container, image and network list calls.

The hermetic tests now verify that empty filter objects remain empty and that a dangling-only image filter reaches the Docker SDK as exactly {"dangling": true}.

Validation

  • ruff check src tests
  • pytest -q: 6 passed
  • Independently reproduced against Docker SDK 7.1.0 and a live Docker daemon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant