Skip to content

Add NAME_FILTER_OPTIONS to FileContent relative_path filter #7719

@dkliban

Description

@dkliban

Problem

FileContentFilter in pulp_file/app/viewsets.py only supports exact matching on the relative_path field:

class Meta:
    model = FileContent
    fields = ["relative_path", "sha256"]

This means API consumers cannot filter file content by path patterns — there is no support for contains, startswith, regex, or other lookup expressions on relative_path.

Other content filters in pulpcore already use NAME_FILTER_OPTIONS for name/path fields (e.g., ContentFilter), so FileContentFilter is inconsistent with the rest of the API.

Proposed fix

Use NAME_FILTER_OPTIONS for relative_path to enable the full set of lookup expressions:

from pulpcore.app.viewsets.base import NAME_FILTER_OPTIONS

class Meta:
    model = FileContent
    fields = {
        "relative_path": NAME_FILTER_OPTIONS,
        "digest": ["exact"],
    }

This enables: exact, iexact, in, contains, icontains, startswith, istartswith, regex, iregex.

The existing sha256 = CharFilter(field_name="digest") alias on the filter class continues to provide backwards-compatible ?sha256= query parameter support.

Use case

Deployments managing large file repositories need to search for content by path prefix (e.g., all files under packages/python/) or by pattern (e.g., all .rpm files). Currently this requires fetching all file content and filtering client-side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions