Skip to content

Fix incorrect 405 response for non-draft version modification#2743

Open
waxlamp wants to merge 3 commits intomasterfrom
fix-405-non-draft-version
Open

Fix incorrect 405 response for non-draft version modification#2743
waxlamp wants to merge 3 commits intomasterfrom
fix-405-non-draft-version

Conversation

@waxlamp
Copy link
Member

@waxlamp waxlamp commented Mar 19, 2026

Fixes #2742

Summary

  • The version update view was bypassing the exception machinery entirely with a raw return Response(...), producing a plain string body instead of the standard error envelope. It now raises PublishedDandisetNotModifiableError consistently with the rest of the API.
  • Renamed DraftDandisetNotModifiableErrorPublishedDandisetNotModifiableError, 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 envelope
  • test_asset_rest_create_published_version — unchanged status, consistent error format
  • test_asset_rest_update_published_version — unchanged status, consistent error format
  • test_asset_rest_delete_published_version — unchanged status, consistent error format

waxlamp and others added 2 commits March 19, 2026 13:51
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>
@waxlamp waxlamp requested a review from jjnesbitt March 19, 2026 18:20
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>
@jjnesbitt
Copy link
Member

We should probably return the Allow header, which would require us to add some field to that exception, and update the exception wrapping here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PUT /api/dandisets/{id}/versions/{version}/ returns incorrect 405 for non-draft versions

2 participants