Skip to content

Add NAME_FILTER_OPTIONS to FileContent relative_path filter#7720

Merged
dkliban merged 1 commit into
pulp:mainfrom
dkliban:file-content-filter-options
May 19, 2026
Merged

Add NAME_FILTER_OPTIONS to FileContent relative_path filter#7720
dkliban merged 1 commit into
pulp:mainfrom
dkliban:file-content-filter-options

Conversation

@dkliban
Copy link
Copy Markdown
Member

@dkliban dkliban commented May 14, 2026

Summary

  • Use NAME_FILTER_OPTIONS for relative_path in FileContentFilter, enabling contains, startswith, regex, and other lookup expressions
  • Change fields from a list to a dict to specify per-field filter options
  • sha256 query parameter continues to work via the existing CharFilter alias

Fixes #7719

Test plan

  • Existing file content filter tests pass
  • New filter lookups work: ?relative_path__contains=foo, ?relative_path__startswith=packages/, ?relative_path__regex=.*\.rpm$

@dkliban dkliban force-pushed the file-content-filter-options branch 3 times, most recently from 29684e5 to 963b4f4 Compare May 14, 2026 20:41
Comment thread CHANGES/pulp_file/7719.feature Outdated
Comment thread pulp_file/app/viewsets.py
fields = ["relative_path", "sha256"]
fields = {
"relative_path": NAME_FILTER_OPTIONS,
"digest": ["exact"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should still be sha256.

Suggested change
"digest": ["exact"],
"sha256": ["exact"],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reverted back to "digest". When Meta.fields is a dict, django-filter requires model field names as keys — sha256 is a declared CharFilter alias, not a model field, so it raises TypeError: Meta.fields must not contain non-model field names: sha256. The sha256 = CharFilter(field_name="digest") on the class still provides the ?sha256= query parameter for backwards compatibility.

@dkliban dkliban force-pushed the file-content-filter-options branch from 963b4f4 to 337472e Compare May 16, 2026 01:49
FileContentFilter only supported exact matching on relative_path.
Use NAME_FILTER_OPTIONS to enable contains, startswith, regex, and
other lookup expressions, consistent with other content filters.

Fixes pulp#7719

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dkliban dkliban force-pushed the file-content-filter-options branch from 337472e to 7815029 Compare May 18, 2026 12:38
@ggainey ggainey enabled auto-merge (rebase) May 19, 2026 13:08
@dkliban
Copy link
Copy Markdown
Member Author

dkliban commented May 19, 2026

The test failure is unrelated to these changes. It is being addressed in #7730. I am merging this change.

@dkliban dkliban disabled auto-merge May 19, 2026 15:08
@dkliban dkliban merged commit 4e58f91 into pulp:main May 19, 2026
33 of 40 checks passed
@dkliban dkliban deleted the file-content-filter-options branch May 19, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add NAME_FILTER_OPTIONS to FileContent relative_path filter

2 participants