Bug 1010292 - Key error on unit search
Key error on unit search
Status: CLOSED CURRENTRELEASE
Product: Pulp
Classification: Community
Component: API/integration (Show other bugs)
unspecified
Unspecified Unspecified
low Severity medium
: ---
: 2.3.0
Assigned To: Jeff Ortel
Preethi Thomas
: Triaged
Depends On:
Blocks: 1008020
  Show dependency treegraph
 
Reported: 2013-09-20 09:05 EDT by David Davis
Modified: 2013-12-09 09:31 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-12-09 09:31:42 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)

  None (edit)
Description David Davis 2013-09-20 09:05:55 EDT
Hitting a key error when doing unit searches:

[ERROR 2013-09-20 08:42:20 pulp_rest] RestClient.post "https://localhost/pulp/api/v2/content/units/rpm/search/", 632 byte(s) length, "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"OAuth oauth_body_hash=\"2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D\", oauth_consumer_key=\"katello\", oauth_nonce=\"IospyJPoxnUr1CtazULH9lqGwYvonhsMbJmyj2iOU\", oauth_signature=\"iqFplE%2FIIwAvH9g56O46%2Fs3qB9I%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1379680940\", oauth_version=\"1.0\"", "Content-Length"=>"632", "accept"=>"application/json", "content_type"=>"application/json", "pulp-user"=>"admin"
 | \n# => 500 InternalServerError | application/json 4595 bytes


Pulp error:

2013-09-20 08:42:20,152 pulp.server.webservices.middleware.exception:ERROR: Unhandled Exception
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/middleware/exception.py", line 44, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/middleware/postponed.py", line 39, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 279, in wsgi
    result = self.handle_with_processors()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 26, in _handle_with_processors
    return process(self.processors)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 566, in processor
    return handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 581, in processor
    result = handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 25, in process
    return self.handle()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 422, in _delegate
    return f()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 430, in <lambda>
    f = lambda: self._delegate_sub_application(pat, what)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 455, in _delegate_sub_application
    return app.handle_with_processors()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 26, in _handle_with_processors
    return process(self.processors)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 566, in processor
    return handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in process
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/web/application.py", line 581, in processor
    result = handler()
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 23, in <lambda>
    return p(lambda : process(processors))
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/application.py", line 25, in process
    return self.handle()
  File "/usr/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 405, in _delegate
    return handle_class(f)
  File "/usr/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
    return tocall(*args)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/decorators.py", line 227, in _auth_decorator
    value = method(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/contents.py", line 184, in POST
    units = [ContentUnitsCollection.process_unit(unit) for unit in raw_units]
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/controllers/contents.py", line 73, in process_unit
    unit = serialization.content.content_unit_obj(unit)
  File "/usr/lib/python2.7/site-packages/pulp/server/webservices/serialization/content.py", line 43, in content_unit_obj
    last_updated = content_unit['_last_updated']
KeyError: '_last_updated'
Comment 2 Justin Sherrill 2013-09-20 14:38:51 EDT
POST  https://localhost/pulp/api/v2/content/units/rpm/search/

With BodY:

{"criteria":{"filters":{"_id":{"":["b9bc6e1d-b76a-4483-92d5-b122c9b31d44"]}},"fields":["name","version","release","arch","suffix","epoch","download_url","checksum","checksumtype","license","group","children","vendor","filename","relativepath","description","size","buildhost","_id","_content_type_id","_href","_storage_path","_type"]},"include_repos":true}
Comment 3 Justin Sherrill 2013-09-20 14:41:55 EDT
Seems that this bug is caused by us specifying a particular set of fields.  If _last_updated is not in the list, the query will fail, if it is in the list, it will work properly.

Lowering the priority on this bug, but ideally pulp should handle us not requesting _last_updated.
Comment 4 Jeff Ortel 2013-10-02 13:15:25 EDT
https://github.com/pulp/pulp/pull/647
Comment 5 Jeff Ortel 2013-10-11 11:26:09 EDT
build: 2.3.0-0.18.beta
Comment 6 Preethi Thomas 2013-10-15 16:40:56 EDT
verified

query does not fail when _last_updated not given

In [48]:  pic.POST('/pulp/api/v2/content/units/rpm/search/',body={"criteria":{"filters":{"_id":{"":["88ee9fa2-0c01-4a48-88b4-dc18460ae76d"]}},"fields":["name","version","release","arch","suffix","epoch","download_url","checksum","checksumtype","license","group","children","vendor","filename","relativepath","description","size","buildhost","_id","_content_type_id","_href","_storage_path","_type"]},"include_repos":True})
   ....: 
Request Body
{
  "include_repos": true, 
  "criteria": {
    "fields": [
      "name", 
      "version", 
      "release", 
      "arch", 
      "suffix", 
      "epoch", 
      "download_url", 
      "checksum", 
      "checksumtype", 
      "license", 
      "group", 
      "children", 
      "vendor", 
      "filename", 
      "relativepath", 
      "description", 
      "size", 
      "buildhost", 
      "_id", 
      "_content_type_id", 
      "_href", 
      "_storage_path", 
      "_type"
    ], 
    "filters": {
      "_id": {
        "": [
          "88ee9fa2-0c01-4a48-88b4-dc18460ae76d"
        ]
      }
    }
  }
}
Response Body
[]
Out[48]: (200, [])
Comment 7 Preethi Thomas 2013-12-09 09:31:42 EST
Pulp 2.3 released.

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