401 and 404 errors from the heat API are not returned with JSON content type

Bug #1367062 reported by Miguel Grinberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Invalid
Low
Unassigned
keystonemiddleware
Fix Released
Low
Colleen Murphy

Bug Description

While 400 errors are returned with a JSON response, 401 and 404 errors are inconsistently returned with either text/plain or text/html.

Examples (using httpie client from the command line):

$ http GET http://192.168.33.10:8004/v1/14d6f71c653d4ba5ad4a2320411a0ea8/stacks
HTTP/1.1 401 Unauthorized
Content-Length: 23
Content-Type: text/plain
Date: Tue, 09 Sep 2014 01:27:03 GMT
Www-Authenticate: Keystone uri='http://192.168.33.10:5000/v2.0'
X-Openstack-Request-Id: req-7e28f211-1e82-4fb1-a2bd-a99af63c25df

Authentication required

$ http GET http://192.168.33.10:8004/v1/14d6f71c653d4ba5ad4a2320411a0ea8/validate X-Auth-Token:XXXXX
HTTP/1.1 404 Not Found
Content-Length: 154
Content-Type: text/html; charset=UTF-8
Date: Tue, 09 Sep 2014 01:19:25 GMT
X-Openstack-Request-Id: req-a6547443-1d0e-410a-99cd-0e27c63e3817

<html>
 <head>
  <title>404 Not Found</title>
 </head>
 <body>
  <h1>404 Not Found</h1>
  The resource could not be found.<br /><br />

 </body>
</html>

Changed in heat:
status: New → Triaged
importance: Undecided → Low
Changed in heat:
assignee: nobody → Miguel Grinberg (miguelgrinberg)
Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :

The 401 errors returned by heat API come from the keystonemiddleware package. Since this is a project used by many clients it may be wise to implement content negotiation and offer responses in several content-types to satisfy all clients.

summary: - 404 errors from the heat API are not returned with JSON content type
+ 401 and 404 errors from the heat API are not returned with JSON content
+ type
Dolph Mathews (dolph)
Changed in keystonemiddleware:
status: New → Triaged
importance: Undecided → Low
tags: added: user-experience
jiaxi (tjxiter)
Changed in keystonemiddleware:
assignee: nobody → jiaxi (tjxiter)
jiaxi (tjxiter)
Changed in keystonemiddleware:
assignee: jiaxi (tjxiter) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystonemiddleware (master)

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

Changed in keystonemiddleware:
assignee: nobody → Colleen Murphy (krinkle)
status: Triaged → In Progress
Revision history for this message
Steve Martinelli (stevemar) wrote :

Marking heat as invalid, this is a keystonemiddleware bug

Changed in heat:
status: Triaged → Invalid
assignee: Miguel Grinberg (miguelgrinberg) → nobody
Revision history for this message
Colleen Murphy (krinkle) wrote :

Steve - I don't think it's invalid, as the 404 error is returned directly from heat, not keystonemiddleware.

Changed in heat:
status: Invalid → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystonemiddleware (master)

Reviewed: https://review.openstack.org/309606
Committed: https://git.openstack.org/cgit/openstack/keystonemiddleware/commit/?id=8d52a83a0849a83427f422c1e1df62159bccca83
Submitter: Jenkins
Branch: master

commit 8d52a83a0849a83427f422c1e1df62159bccca83
Author: Colleen Murphy <email address hidden>
Date: Fri Apr 22 14:46:19 2016 -0700

    Return JSON for Unauthorized message

    To be consistent with how keystone formats 401 responses,
    keystonemiddleware should also return JSON when auth_token fails to
    authenticate. This patch modifies the response to use the
    application/json Content-Type and formats the body in the same way that
    keystone does[1]

    [1] http://git.openstack.org/cgit/openstack/keystone/tree/keystone/common/wsgi.py?h=9.0.0&id=3e5fca06c6b7dd6060721faa39428b133edd10f0#n812

    Change-Id: I6601862ef948b50dedba033c03a42acedbfc8d90
    Closes-bug: #1367062

Changed in keystonemiddleware:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/keystonemiddleware 4.5.0

This issue was fixed in the openstack/keystonemiddleware 4.5.0 release.

Revision history for this message
Jason Dunsmore (jasondunsmore) wrote :

404 and 401 return "Content-Type: application/json" with the latest Heat on a recent devstack.

Changed in heat:
status: Confirmed → 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.