Skip to content

Evaluate the preconditions of a conditional write to a resource that cannot be read (#1753) - #1757

Merged
thboileau-git merged 2 commits into
3.0from
fix/1753-write-only-conditional-put
Nov 29, 2026
Merged

thboileau-git merged 2 commits into
3.0from
fix/1753-write-only-conditional-put

Conversation

@thboileau-git

@thboileau-git thboileau-git commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1753

A resource that supports PUT but not GET (an annotated @Put only) answered 405 to a conditional PUT. The validators are retrieved through the GET handling, whose 405 was kept, so the PUT that the resource supports was never attempted. Without the conditional header the same PUT worked.

  • When retrieving the validators gives nothing, the status is 405, the method is not GET or HEAD, and the resource declares that it does not support GET (updateAllowedMethods(), the annotated methods by default), the 405 of the missing GET is discarded (with its Allow header) and the preconditions are evaluated as for a resource with no known representation: If-Match fails with 412, If-None-Match passes (so "create only" is not enforced on a resource that cannot be read, said in the Javadoc).
  • A resource that declares nothing (for example one that overrides put() without annotating it) is not changed: the framework does not guess at overridden methods. It can declare them with updateAllowedMethods().
  • An error set by the resource's own get() / getInfo() is still kept (Precondition Checks should honor set status #129), and a resource that overrides getInfo() to provide its validators gets real conditional writes (Javadoc of doConditionalHandle).
  • No new API. Fix on by default in the three trees (the old answer was a refusal in every case).
  • Tests: ServerResourceWriteOnlyTestCase (unit, with guards) and three cases in the wire-level MethodNotAllowedWireTestCase. Red before the fix on each tree.

Same fix on the other maintained versions: PR #1758 (2.7) and #1759 (2.6)

🤖 Generated with Claude Code

…cannot be read (#1753)

A resource that supports PUT but not GET (an annotated @put only) answered 405
to a conditional PUT: the validators are retrieved through the GET handling,
whose 405 was kept, so the PUT supported by the resource was never attempted.

When the resource declares that it does not support GET (the annotated methods,
or ServerResource.updateAllowedMethods()), the 405 of the missing GET is now
discarded and the preconditions are evaluated as for a resource with no known
representation: If-Match fails with 412, If-None-Match passes. A resource that
declares nothing, and an error set by the resource itself, are not changed. The
resource can override getInfo() to provide its validators.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…cognitive complexity (#1753)

Sonar S3776 on doConditionalHandle() (16 for 15 allowed) after the #1753 change.
No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@thboileau-git
thboileau-git merged commit 03625ce into 3.0 Nov 29, 2026
3 of 4 checks passed
@thboileau-git
thboileau-git deleted the fix/1753-write-only-conditional-put branch November 29, 2026 16:57
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.

2 participants