Bug 1010292

Summary: Key error on unit search
Product: [Retired] Pulp Reporter: David Davis <daviddavis>
Component: API/integrationAssignee: Jeff Ortel <jortel>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: medium Docs Contact:
Priority: low    
Version: unspecifiedCC: daviddavis, jsherril, omaciel, pthomas, skarmark
Target Milestone: ---Keywords: Triaged
Target Release: 2.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-09 14:31:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1008020    

Description David Davis 2013-09-20 13:05:55 UTC
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 18:38:51 UTC
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 18:41:55 UTC
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 17:15:25 UTC
https://github.com/pulp/pulp/pull/647

Comment 5 Jeff Ortel 2013-10-11 15:26:09 UTC
build: 2.3.0-0.18.beta

Comment 6 Preethi Thomas 2013-10-15 20:40:56 UTC
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 14:31:42 UTC
Pulp 2.3 released.