Value error from self.img_client.get_image("")

Bug #900915 reported by Nachi Ueno
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Invalid
High
Rohit Karajgi

Bug Description

Value error from self.img_client.get_image("")
We wanna get error code from server.

-REST API
 https://servers.api.openstack.com/v1.1/{tenantId}/images/{imageId}

-Error
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/home/openstack/workspace/openstack-integration-tests/medium/tests/test_images.py", line 1000, in test_get_image_when_image_id_is_empty_string
     self.img_client.get_image(image_id)
   File "/home/openstack/workspace/openstack-integration-tests/storm/services/nova/json/images_client.py", line 75, in get_image
     body = json.loads(body)
   File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
     return _default_decoder.decode(s)
   File "/usr/lib/python2.7/json/decoder.py", line 363, in decode
     raise ValueError(errmsg("Extra data", s, end, len(s)))
 ValueError: Extra data: line 1 column 4 - line 5 column 4 (char 4 - 52)
 ----------------------------------------------------------------------

Nachi Ueno (nati-ueno)
Changed in tempest:
assignee: nobody → Rohit Karajgi (rohitkarajgi)
Revision history for this message
Daryl Walleck (dwalleck) wrote :

This is fixed in my latest submission. The error is because the error body couldn't be parsed. Instead, I raise an exception from the rest client specific to the error code and include the error message.

https://review.openstack.org/#change,2094

Revision history for this message
Rohit Karajgi (rohitk) wrote :

Hi Daryl,

In this particular use case, when we pass nothing to the images GET request (or blank image id), an HTTP 404 itemNotFound is returned. Not sure but is this handled in your change request?

Revision history for this message
Rohit Karajgi (rohitk) wrote :

I'll submit a patch to add it, in case.

Revision history for this message
Rohit Karajgi (rohitk) wrote :

Ok, there are two uses cases here:
1. self.img_client.get_image("") - which translates to

 https://servers.api.openstack.com/v1.1/{tenantId}/images/ - here image_id is empty.

This returns an HTTP 404 "The resource could not be found" message only.

2. self.img_client.get_image("32fgg") - invalid image ID which translates to
 https://servers.api.openstack.com/v1.1/{tenantId}/images/32fgg

This also returns an HTTP 404 but with a json Body like so:
{
  "itemNotFound" : {
    "message" : "Image not found.",
    "code" : 404
  }
}

I think case 1 should be handled in the images_client by checking for empty parameters and case 2 should be a valid scenario and raise the appropriate exception, for which I'll submit the patch.

Revision history for this message
Nachi Ueno (nati-ueno) wrote :

Hi Daryl

I created list of HTTP codes on OpenStack
https://docs.google.com/spreadsheet/ccc?key=0Ap9P99ymj9wLdEVIUllpRmZMaU04RUNNMVEycU9GOUE&hl=ja#gid=0

Following error codes should be added
414 Request-URI Too Large
405 Method Not Allowed
415 Unsupported Media Type
401 Unauthorized
403 Forbidden
501 Not Implemented
409 Conflict
403 Forbidden
408 Request Time-out

Rohit can submit patch for this.

Revision history for this message
Nachi Ueno (nati-ueno) wrote :

Sorry #5 is not for this bug

Revision history for this message
Nachi Ueno (nati-ueno) wrote :

Sorry again, #5 is for this bug.

>Rohit
Rest Client should not check input value for negative case.
We should test both of case

Rohit Karajgi (rohitk)
Changed in tempest:
status: New → In Progress
importance: Undecided → High
Rohit Karajgi (rohitk)
Changed in tempest:
milestone: none → essex-2
tags: added: testcase
tags: added: compute
Nachi Ueno (nati-ueno)
tags: removed: compute testcase
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi guys, can we get an update on whether this bug still exists or is still valid?

Thanks!
-jay

Changed in tempest:
milestone: essex-2 → essex-3
status: In Progress → Incomplete
Jay Pipes (jaypipes)
Changed in tempest:
status: Incomplete → Invalid
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.