Bug 1021579 - No error when criteria inside request body lack the required type_ids (when unassociating this results in an empty repository)
No error when criteria inside request body lack the required type_ids (when u...
Status: CLOSED UPSTREAM
Product: Pulp
Classification: Community
Component: API/integration (Show other bugs)
2.2
Unspecified Unspecified
medium Severity medium
: ---
: 3.0.0
Assigned To: pulp-bugs
pulp-qe-list
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-21 10:51 EDT by Vincent Van Driessche
Modified: 2015-02-28 16:59 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-02-28 16:59:27 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Pulp Redmine 379 None None None Never

  None (edit)
Description Vincent Van Driessche 2013-10-21 10:51:03 EDT
Description of problem:
While making a script to remove a set of packages, I encountered a stubborn error: When performing a POST request to "/pulp/api/v2/repositories/pulp2-cleanup-test/actions/unassociate/" with message body resembling following json: 
{'criteria': 
  {'filters': 
    {'unit': 
      {'unit_id': 
        {'$in': 
          ['5b1feecc-5b48-40a6-a890-39f0bf5b3960']
        }
      }
    }
  }
}
I ran into the fact that it did not remove the package with ID 5b1feecc-5b48-40a6-a890-39f0bf5b3960; It removed ALL of the repositories packages.

After some talking to the developers I was pointed out that without a type_id specified, the filters would all be dropped, what remains was an unassociate query without filtering: resulting in every package being removed.

This is how the packages are not all being dropped any longer:
{"criteria":
  {"filters":
    {"unit":
      {"unit_id": 
        {"$in":
          ['5b1feecc-5b48-40a6-a890-39f0bf5b3960']
        }
      }
    },
     "type_ids":["rpm"]
  }
}

I do think this should be properly documented or/and should throw an error instead of just wiping out repositories. ^^


Kind regards

Vincent
Comment 1 Chris Duryee 2014-11-18 15:42:27 EST
I would consider this to be an API bug, it is unexpected that all of the units are unassociated. I will document it for now but it should be fixed for Pulp 3.0.
Comment 2 Chris Duryee 2014-11-18 15:54:30 EST
doc update: https://github.com/pulp/pulp/pull/1327
Comment 3 Chris Duryee 2014-11-20 16:28:31 EST
docs update is merged to 2.4-release and up, changing BZ component to API/integration for the actual fix
Comment 4 amacdona@redhat.com 2015-02-26 13:50:21 EST
This is the case for more than just this call. Many API calls that use critera to filter results have a similar issue.
Comment 5 Brian Bouterse 2015-02-28 16:59:27 EST
Moved to https://pulp.plan.io/issues/379

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