Prevent PUT requests to list resources.

Review Request #13284 — Created Sept. 22, 2023 and submitted — Latest diff uploaded

Information

Djblets
release-4.x

Reviewers

We've had a long-standing bug in the API where making a PUT request to a
list resource would generally cause a crash (depending on the particular
implementation of the resource's update method, most of which end up
trying to call get_object without the necessary object key in the
kwargs).

This change makes it so that attempting to PUT to a list resource will
fail with an HTTP 405. We had a similar implementation for POST to item
resources, so this implementation is based on that.

  • Did a PUT to a list resource and saw that I got back an HTTP 405
    (method not allowed) instead of a 500 and HTML error content.
  • Ran unit tests.
  • Updated Review Board unit tests to test this functionality for all
    list resources.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4

Commits

First Last Summary ID Author
Prevent PUT requests to list resources.
We've had a long-standing bug in the API where making a PUT request to a list resource would generally cause a crash (depending on the particular implementation of the resource's `update` method, most of which end up trying to call `get_object` without the necessary object key in the kwargs). This change makes it so that attempting to PUT to a list resource will fail with an HTTP 405. We had a similar implementation for POST to item resources, so this implementation is based on that. Testing Done: - Did a PUT to a list resource and saw that I got back an HTTP 405 (method not allowed) instead of a 500 and HTML error content. - Ran unit tests. - Updated Review Board unit tests to test this functionality for all list resources.
09a5ffa13718d882590a2a5d49134cb90fb06b1e David Trowbridge
djblets/webapi/resources/base.py
djblets/webapi/tests/test_webapiresource.py
Loading...