Fix incorrect 405 response for non-draft version modification#2743
Open
Fix incorrect 405 response for non-draft version modification#2743
Conversation
Raises DraftDandisetNotModifiableError (422 Unprocessable Entity) instead of returning a raw 405 response when a PUT is attempted on a non-draft version. This fixes two issues: 405 Method Not Allowed has a specific HTTP meaning (the method itself is unsupported) that doesn't apply here, and the raw Response body was inconsistent with the standard error format used elsewhere in the API. The same fix is applied to the asset service, which had the same bug via DraftDandisetNotModifiableError. Fixes #2742 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…bleError It is published (non-draft) versions that cannot be modified, not draft ones. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PUT on a published version is genuinely not allowed, making 405 Method Not Allowed the correct status code. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
We should probably return the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2742
Summary
updateview was bypassing the exception machinery entirely with a rawreturn Response(...), producing a plain string body instead of the standard error envelope. It now raisesPublishedDandisetNotModifiableErrorconsistently with the rest of the API.DraftDandisetNotModifiableError→PublishedDandisetNotModifiableError, since it is published (non-draft) versions that cannot be modified.The status code remains 405: PUT on a published version is genuinely not supported, so Method Not Allowed is correct.
Test plan
test_version_rest_update_not_a_draft— response body is now the standard error envelopetest_asset_rest_create_published_version— unchanged status, consistent error formattest_asset_rest_update_published_version— unchanged status, consistent error formattest_asset_rest_delete_published_version— unchanged status, consistent error format