Project

Profile

Help

Issue #826

closed

missing criteria field should not return all possible results

Added by amacdona@redhat.com about 9 years ago. Updated about 5 years ago.

Status:
CLOSED - WONTFIX
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

There are multiple ways that our use of criteria can have unexpected results, but they all center around the fact that some search results start with all results and filter by the criteria that is passed in. This means that if the criteria is incorrect in some way that everything is returned.

For example, if I pass empty criteria to unassociate, I would expect that none of the content is unassociated. Instead all content (of the repo) is unassociated.

$ pulp-admin -u admin -p admin rpm repo list

    +----------------------------------------------------------------------+
                                RPM Repositories
    +----------------------------------------------------------------------+

    Id:                  zoo1
    Display Name:        zoo1
    Description:         None
    Content Unit Counts:
      Rpm: 32

$ curl -i -H "Accept: application/json" -H "WebFrameworkSwitch: webpy" -X POST -k -u admin:admin -d '{"criteria":{}}' "https://localhost/pulp/api/v2/repositories/zoo1/actions/unassociate/"

HTTP/1.1 202 Accepted
Date: Wed, 25 Mar 2015 16:03:47 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 172
Content-Type: application/json
    {"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/757a7a4f-23d8-4f9e-a6a8-0ec1efabe149/", "task_id": "757a7a4f-23d8-4f9e-a6a8-0ec1efabe149"}], "result": null, "error": null}

$ pulp-admin -u admin -p admin rpm repo list


    +----------------------------------------------------------------------+
                                RPM Repositories
    +----------------------------------------------------------------------+

    Id:                  zoo1
    Display Name:        zoo1
    Description:         None
    Content Unit Counts:
      Rpm: 0

Similar problems can occur if there are typos in the field names. For instance passing 'distributor_id' instead of 'id'. 'distributor_id' would match nothing,so all distributors would be returned instead of just the ids listed or a 400.

It would be my expectation for the opposite to happen. If I pass bad params, they should either return a 400 or null results. Likewise, passing nothing should either be a validation error or null.

Actions #1

Updated by amacdona@redhat.com about 9 years ago

If criteria is not set, it defaults to None. Deep in pulp, this None is converted into an empty criteria, which again returns all possible results.

Even if 'criteria': {} is mongo for "all", not specifying a criteria definitely should not mean all.

$ pulp-admin rpm repo list


+----------------------------------------------------------------------+
                            RPM Repositories
+----------------------------------------------------------------------+

Id:                  zoo
Display Name:        zoo
Description:         None
Content Unit Counts: 
  Erratum:          4
  Package Category: 1
  Package Group:    2
  Rpm:              32

$ curl -i -H "Accept: application/json" -X POST -d '{}' -k -u admin:admin "https://localhost/pulp/api/v2/repositories/zoo/actions/unassociate/"

HTTP/1.1 202 ACCEPTED
Date: Wed, 01 Apr 2015 20:32:10 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1k-fips mod_wsgi/4.3.2 Python/2.7.8
Content-Encoding: utf-8
Content-Length: 172
Content-Type: application/json

{
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/03e8b8b4-b5a3-44ec-81a3-c03c1c89a53b/",
            "task_id": "03e8b8b4-b5a3-44ec-81a3-c03c1c89a53b"
        }
    ],
    "result": null,
    "error": null
}

$ pulp-admin rpm repo list

+----------------------------------------------------------------------+
                            RPM Repositories
+----------------------------------------------------------------------+

Id:                  zoo
Display Name:        zoo
Description:         None
Content Unit Counts: 
  Erratum:          0
  Package Category: 0
  Package Group:    0
  Rpm:              0
Actions #2

Updated by amacdona@redhat.com about 9 years ago

  • Project changed from Puppet Support to Pulp
  • Subject changed from missing or bad criteria should not return all possible results to missing should not return all possible results
  • Tags Easy Fix added
Actions #3

Updated by amacdona@redhat.com about 9 years ago

  • Subject changed from missing should not return all possible results to missing criteria field should not return all possible results
Actions #4

Updated by amacdona@redhat.com about 9 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to amacdona@redhat.com
Actions #5

Updated by amacdona@redhat.com about 9 years ago

  • Status changed from ASSIGNED to POST
Actions #6

Updated by mhrivnak about 9 years ago

  • Severity changed from 2. Medium to 1. Low
  • Triaged changed from No to Yes
  • Tags deleted (Easy Fix)
Actions #7

Updated by amacdona@redhat.com about 9 years ago

  • Status changed from POST to NEW

I made a PR to enforce the existence of criteria, but since we decided that this was backwards incompatible, I closed the PR.

https://github.com/pulp/pulp/pull/1759

Actions #8

Updated by amacdona@redhat.com almost 9 years ago

  • Assignee deleted (amacdona@redhat.com)
Actions #9

Updated by bmbouter about 5 years ago

  • Status changed from NEW to CLOSED - WONTFIX
Actions #10

Updated by bmbouter about 5 years ago

Pulp 2 is approaching maintenance mode, and this Pulp 2 ticket is not being actively worked on. As such, it is being closed as WONTFIX. Pulp 2 is still accepting contributions though, so if you want to contribute a fix for this ticket, please reopen or comment on it. If you don't have permissions to reopen this ticket, or you want to discuss an issue, please reach out via the developer mailing list.

Actions #11

Updated by bmbouter about 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF