placement api requires content-type on put and post even when no body

Bug #1674392 reported by Chris Dent
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Chris Dent

Bug Description

The placement API a guarding condition which checks the request method. If it is PUT, POST or PATCH the presence of a content-type header is required.

This is too strict (but happened to work fine for the api at the time). It is reasonable and okay to make a PUT or POST without a body, and thus without a content-type, and now we want to do such things within the placement API (with putting custom traits and resource classes).

The fix is to only raise the 400 when content-length is set and non-zero. In that case a missing content-type is a bug, irrespective of method.

Tags: placement
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: Chris Dent (cdent) → Alex Xu (xuhj)
Changed in nova:
assignee: Alex Xu (xuhj) → Chris Dent (cdent)
Changed in nova:
assignee: Chris Dent (cdent) → Alex Xu (xuhj)
Changed in nova:
assignee: Alex Xu (xuhj) → Chris Dent (cdent)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/447625
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=6dd047a3307a1056077608fd5bc2d1c3b3285338
Submitter: Jenkins
Branch: master

commit 6dd047a3307a1056077608fd5bc2d1c3b3285338
Author: Chris Dent <email address hidden>
Date: Mon Mar 20 17:46:27 2017 +0000

    [placement] Allow PUT and POST without bodies

    We plan to allow PUT requests to create/update both custom traits
    and custom resource classes, without bodies. Prior to this change,
    the code would not all a PUT, POST or PATCH to not have a body. This was
    added in I6e7dffb5dc5f0cdc78a57e8df3ae9952c55163ae which was fixing an
    issue with how webob handles exceptions.

    This change does two things:

    * It address the problem from bug #1623517, fixed in the change id'd
      above, in a more narrow fashion, making sure the data source that
      causes the KeyError is non-empty right before it is used. This allows
      simplifying the following change.
    * If a request has a content-length (indicating the presence of a body),
      verify that there is also a content-type. If not, raise a 400.

    basic-http.yaml has been change to modify one gabbi test to check a
    response body is correct and to add another test to confirm that the
    code that is doing the content-length check is passed through.

    Change-Id: Ifb7446fd02ba3e54bbe2676dfd38e5dfecd15f98
    Closes-Bug: #1674392
    Related-Bug: #1623517

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 16.0.0.0b1

This issue was fixed in the openstack/nova 16.0.0.0b1 development milestone.

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.