Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulp_href__in filter doesn't handle empty set properly #4437

Closed
daviddavis opened this issue Sep 18, 2023 · 1 comment · Fixed by #4439
Closed

pulp_href__in filter doesn't handle empty set properly #4437

daviddavis opened this issue Sep 18, 2023 · 1 comment · Fixed by #4439
Labels

Comments

@daviddavis
Copy link
Contributor

We make use of the pulp_href__in filter and it works great. We store pulp hrefs for some various things and we can easily look up the resources in pulp using this filter.

There is an edge case that I don't think it's properly handling though. It certain cases, the set will be empty and when we pass that to pulp, it seems that all results get returned. I think that no results should instead be returned.

Current behavior:

$ http :8080/pulp/api/v3/repositories/ pulp_href__in==
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "description": null,
            "latest_version_href": "/pulp/api/v3/repositories/deb/apt/1cc3ba78-bbf6-4373-b742-725785f010be/versions/0/",
            "name": "pmc_cli_test_repo_8fa0535e-c76f-4a60-8c1d-257290ec88c2",
            "pulp_created": "2023-09-18T12:46:41.212285Z",
            "pulp_href": "/pulp/api/v3/repositories/deb/apt/1cc3ba78-bbf6-4373-b742-725785f010be/",
            "pulp_labels": {},
            "remote": null,
            "retain_repo_versions": null,
            "versions_href": "/pulp/api/v3/repositories/deb/apt/1cc3ba78-bbf6-4373-b742-725785f010be/versions/"
        }
    ]
}

Expected behavior:

No results (ie []) get returned.

@daviddavis
Copy link
Contributor Author

Looks like the problem is with django-filter: carltongibson/django-filter#1609

daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in filter returns all
results instead of no results.

 The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in filter returns all
results instead of no results.

 The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in filter returns all
results instead of no results.

 The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in or pulp_id__in filters
return all results instead of no results.

The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in or pulp_id__in filters
return all results instead of no results.

The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
daviddavis added a commit to daviddavis/pulpcore that referenced this issue Sep 18, 2023
Fix bug where empty list for the pulp_href__in or pulp_id__in filters
return all results instead of no results.

The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes pulp#4437
dralley pushed a commit that referenced this issue Sep 20, 2023
Fix bug where empty list for the pulp_href__in or pulp_id__in filters
return all results instead of no results.

The problem is that when using FilterMethod, django-filter just simply
ignores None and empty set and returns the full list of results:

https://github.com/carltongibson/django-filter/blob/e4a70a667a0bf3882fd44b557bc76583d2c65cd1/django_filters/filters.py#L804-L805

There's no way to update the method to prevent this since this logic
happens before the method is called. Instead, this change moves the
method to the filter and adds a None check.

fixes #4437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants