Skip to content

fix: match ps --filter keys exactly instead of by prefix - #5197

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
immanuwell:fix-ps-filter-prefix-match
Sep 11, 2026
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
immanuwell:fix-ps-filter-prefix-match

Conversation

@immanuwell

@immanuwell immanuwell commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

nerdctl ps --filter matches the filter key with strings.HasPrefix, so any key that starts with a supported one gets misrouted: --filter labels=env runs as label=env, --filter name2=foo as name=foo.
Docker rejects these, and nerdctl already rejects other unknown filters like driver=x

Fix: split on = once and match the key exactly.
Unknown keys hit the existing invalid filter error.
Valid filters (label=k=v included) are unchanged

Repro before this change:

nerdctl run -d --net none --name f1 --label env=prod alpine sleep 600
nerdctl ps --filter 'labels=env'

nerdctl: prints f1, exit 0
docker: invalid filter 'labels', exit 1

Signed-off-by: Immanuel Tikhonov <pchpr.00@list.ru>
@immanuwell
immanuwell force-pushed the fix-ps-filter-prefix-match branch from 0f70e24 to 19f87a6 Compare September 9, 2026 17:00
@AkihiroSuda AkihiroSuda added this to the v2.4.0 milestone Sep 10, 2026

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
AkihiroSuda merged commit 01abfd8 into containerd:main Sep 11, 2026
102 of 112 checks passed
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.

2 participants