Bug 1111570 - the "Criteria" object just accepts anything the user gives it
Summary: the "Criteria" object just accepts anything the user gives it
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Pulp
Classification: Retired
Component: API/integration
Version: 2.4 Beta
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
: ---
Assignee: pulp-bugs
QA Contact: Irina Gulina
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-20 11:50 UTC by Irina Gulina
Modified: 2015-02-28 23:42 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-19 01:13:49 UTC
Embargoed:


Attachments (Terms of Use)
invalid parameter (544 bytes, text/plain)
2014-09-08 14:40 UTC, Irina Gulina
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Pulp Redmine 237 0 None None None Never

Description Irina Gulina 2014-06-20 11:50:21 UTC
Description of problem:
It's possible to regenerate applicability data for a nonexisting repo. It returns 200 OK and spawned task reports successful state. 


Version-Release number of selected component (if applicable):
>>rpm -qa pulp-server
pulp-server-2.4.0-0.20.beta.el6.noarch


How reproducible:
always


Steps to Reproduce:
>>pulp-admin -u admin -p admin rpm repo list
+----------------------------------------------------------------------+
                            RPM Repositories
+----------------------------------------------------------------------+

Id:                  gena
Display Name:        gena
Description:         None
Content Unit Counts: 
  Rpm: 3


>>pulp-admin -u admin -p admin rpm repo uploads rpm --repo-id gena --file=dog-4.23-1.noarch.rpm
+----------------------------------------------------------------------+
                              Unit Upload
+----------------------------------------------------------------------+

Extracting necessary metadata for each request...
[==================================================] 100%
Analyzing: dog-4.23-1.noarch.rpm
... completed

Creating upload requests on the server...
[==================================================] 100%
Initializing: dog-4.23-1.noarch.rpm
... completed

Starting upload of selected units. If this process is stopped through ctrl+c,
the uploads will be paused and may be resumed later using the resume command or
cancelled entirely using the cancel command.

Uploading: dog-4.23-1.noarch.rpm
[==================================================] 100%
2423/2423 bytes
... completed

Importing into the repository...
This command may be exited via ctrl+c without affecting the request.


[\]
Running...

Task Succeeded


Deleting the upload request...
... completed

>>curl -i -H "Accept: application/json" -X POST -k -u admin:admin -d '{ "repo_criteria": {  "filters": {"id": {"$in": ["cheburahska"]}}}}' 'https://localhost/pulp/api/v2/repositories/actions/content/regenerate_applicability/'

HTTP/1.1 202 Accepted
Date: Fri, 20 Jun 2014 11:08:02 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Encoding: utf-8
Content-Length: 172
Connection: close
Content-Type: application/json

{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/b75c6b4d-8725-4808-b1da-91b35b2281a4/", "task_id": "b75c6b4d-8725-4808-b1da-91b35b2281a4"}], "result": null, "error": null}

>>pulp-admin -u admin -p admin tasks details --task-id="b75c6b4d-8725-4808-b1da-91b35b2281a4"
+----------------------------------------------------------------------+
                              Task Details
+----------------------------------------------------------------------+

Operations:       content_applicability_regeneration
Resources:        
State:            Successful
Start Time:       2014-06-20T11:08:03Z
Finish Time:      2014-06-20T11:08:03Z
Result:           N/A
Task Id:          b75c6b4d-8725-4808-b1da-91b35b2281a4
Progress Report:  


Expected results:
400 - if one or more of the parameters is invalid

Comment 1 Irina Gulina 2014-06-20 15:00:36 UTC
It's the same for a nonexistent consumer

>>pulp-consumer -p admin status 
This consumer is registered to the server
[localhost] with the ID [cheburashka].

>>curl -i -H "Accept: application/json" -X POST -k -u admin:admin -d '{ "consumer_criteria": {  "filters": {"id": {"$in": ["gena"]}}}}' 'https://localhost/pulp/api/v2/consumers/actions/content/regenerate_applicability/'                                                                                                                                         
HTTP/1.1 202 Accepted
Date: Fri, 20 Jun 2014 14:37:48 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Encoding: utf-8
Content-Length: 172
Connection: close
Content-Type: application/json

{"spawned_tasks": [{"_href": "/pulp/api/v2/tasks/8ec8c11e-8fcf-479b-99ae-81bce34a9344/", "task_id": "8ec8c11e-8fcf-479b-99ae-81bce34a9344"}], "result": null, "error": null}

>>pulp-admin -u admin -p admin tasks details --task-id="8ec8c11e-8fcf-479b-99ae-81bce34a9344"
+----------------------------------------------------------------------+
                              Task Details
+----------------------------------------------------------------------+

Operations:       content_applicability_regeneration
Resources:        
State:            Successful
Start Time:       2014-06-20T14:37:49Z
Finish Time:      2014-06-20T14:37:49Z
Result:           N/A
Task Id:          8ec8c11e-8fcf-479b-99ae-81bce34a9344
Progress Report:

Comment 2 Sayli Karmarkar 2014-06-20 16:37:51 UTC
Irina,

Providing a filer with non-existing consumer or repo id is not considered an invalid parameter. It is a valid filter parameter which just doesn't match any existing repos or consumers. This would have been a valid bug if we were using exact consumer and repo ids instead of filters. Closing as not a bug.

Comment 3 Irina Gulina 2014-06-30 17:13:42 UTC
On 06/24/2014 08:54 AM, Irina Gulina wrote:
> Sayli,
>
> On https://bugzilla.redhat.com/show_bug.cgi?id=1111570
>
> What to do if one makes a typo in a repo name or consumer? How s/he will be able to notice that applicability data will not be generated, if 200 OK is returned?
>
> Regards,
> Irina

There is no current way to handle that right now and that is pretty much
the case with all the apis accepting criteria. Maybe we can create an
RFE to change such APIs to return a dictionary with list that results
after applying filters, like in this case it will contain a list of
consumers and a list of repos that we are using to generate applicability.

-- 
Sayli Karmarkar

Comment 4 Irina Gulina 2014-09-08 14:40:44 UTC
Created attachment 935373 [details]
invalid parameter

Comment 5 Irina Gulina 2014-09-08 14:43:00 UTC
The "Criteria" object just accepts anything the user gives it

It was found on applicability exampel, but it seems the problem is not unique to applicability 

https://github.com/pulp/pulp/blob/master/docs/sphinx/dev-guide/integration/rest-api/consumer/applicability.rst#generate-content-applicability-for-updated-consumers

See attachment.

Comment 6 Brian Bouterse 2015-02-19 01:13:49 UTC
Moved to https://pulp.plan.io/issues/237


Note You need to log in before you can comment on or make changes to this bug.