DB2: GET image with long ID (non-existed) Glance would return 500, but not 404

Bug #1263684 reported by Feilong Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Low
Feilong Wang

Bug Description

GET:
http://9.12.27.148:9292/v1/images/82ff46a0-f49b-4279-bdad-e665c203444477777777777w232323232eer34r3r3r3qer3r3r3r
would return 500 instead of 400.

The root cause is as below:
2013-12-23 07:43:15.387 27806 INFO glance.wsgi.server [687bccf6-ed9e-4efa-988e-a05faafb6c4b 51336fdd98e449ef911f57ad3d03c818 d9f056c22dac4022bf2ebb1ed70fd25e] Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/eventlet/wsgi.py", line 384, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/python2.6/site-packages/keystoneclient/middleware/auth_token.py", line 571, in __call__
    return self.app(env, start_response)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/glance/common/wsgi.py", line 368, in __call__
    response = req.get_response(self.application)
  File "/usr/lib/python2.6/site-packages/webob/request.py", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/lib/python2.6/site-packages/webob/request.py", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.6/site-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.6/site-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/glance/common/wsgi.py", line 620, in __call__
    request, **action_args)
  File "/usr/lib/python2.6/site-packages/glance/common/wsgi.py", line 646, in dispatch
    return method(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/glance/registry/api/v1/images.py", line 312, in show
    image = self.db_api.image_get(req.context, id)
  File "/usr/lib/python2.6/site-packages/glance/db/sqlalchemy/api.py", line 315, in image_get
    force_show_deleted=force_show_deleted)
  File "/usr/lib/python2.6/site-packages/glance/db/sqlalchemy/api.py", line 343, in _image_get
    raise e
DataError: (DataError) ibm_db_dbi::DataError: Statement Execute Failed: [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001 SQLCODE=-99999 'SELECT images.created_at AS images_created_at, images.updated_at AS images_updated_at, images.deleted_at AS images_deleted_at, images.deleted AS images_deleted, images.id AS images_id, images.name AS images_name, images.disk_format AS images_disk_format, images.container_format AS images_container_format, images.size AS images_size, images.status AS images_status, images.is_public AS images_is_public, images.checksum AS images_checksum, images.min_disk AS images_min_disk, images.min_ram AS images_min_ram, images.owner AS images_owner, images.protected AS images_protected, image_properties_1.created_at AS image_properties_1_created_at, image_properties_1.updated_at AS image_properties_1_updated_at, image_properties_1.deleted_at AS image_properties_1_deleted_at, image_properties_1.deleted AS image_properties_1_deleted, image_properties_1.id AS image_properties_1_id, image_properties_1.image_id AS image_properties_1_image_id, image_properties_1.name AS image_properties_1_name, image_properties_1."value" AS image_properties_1_value, image_locations_1.created_at AS image_locations_1_created_at, image_locations_1.updated_at AS image_locations_1_updated_at, image_locations_1.deleted_at AS image_locations_1_deleted_at, image_locations_1.deleted AS image_locations_1_deleted, image_locations_1.id AS image_locations_1_id, image_locations_1.image_id AS image_locations_1_image_id, image_locations_1."value" AS image_locations_1_value, image_locations_1.meta_data AS image_locations_1_meta_data \nFROM images LEFT OUTER JOIN image_properties AS image_properties_1 ON images.id = image_properties_1.image_id LEFT OUTER JOIN image_locations AS image_locations_1 ON images.id = image_locations_1.image_id \nWHERE images.id = ?' ('82ff46a0-f49b-4279-bdad-e665c203444477777777777w232323232eer34r3r3r3qer3r3r3r',)

Tags: db2 error-code
Feilong Wang (flwang)
Changed in glance:
assignee: nobody → Fei Long Wang (flwang)
importance: Undecided → Low
status: New → Confirmed
tags: added: db2
tags: added: error-code
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/63765

Changed in glance:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/63765
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=5de69badfc44dd03e5fa21577a66daabc3ade5a0
Submitter: Jenkins
Branch: master

commit 5de69badfc44dd03e5fa21577a66daabc3ade5a0
Author: Fei Long Wang <email address hidden>
Date: Mon Dec 23 21:57:07 2013 +0800

    Check image id format before executing operations

    DB2 will raise 'CLI0109E String data right truncation' error if
    the given query parameter is longer than the column definition.
    As a result, user will run into 500 instead of 404 error though
    the malformed id is not existed in DB.
    This fix will add image id format checking before executing real
    operations.

    Closes-Bug: #1263684

    Change-Id: I1ab3e38724014032d9290e7dde3f8b6d23b6df6c

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: none → icehouse-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.