Repository navigation
fix(http): refuse if and if_absent together instead of dropping if - #303
Closed
japaneseml wants to merge 1 commit into
Closed
japaneseml wants to merge 1 commit into
japaneseml wants to merge 1 commit into
Conversation
4 tasks done
_condition() returned on the if_absent branch before if= was ever read, so a write sent with both (?if=X&if_absent=1) silently ignored if=. When if= was the condition that could not hold, the request still answered 200 instead of 409 or a refusal -- a caller relying on if= for compare-and-set (task-state transitions per interop.md) could not tell its condition was never checked. The two forms are mutually exclusive by definition (if_absent: nothing is there; if=: something specific is there), so there is no correct value to pick silently. Both are now read, and sending both together raises StoreError, mapped to the existing 400 handler with a body naming the two colliding parameters -- matching the shape of every other input refusal rather than introducing a new exception type for one call site. core/app.py grows 981 -> 984 code lines for the extra branch and raise; sz-baseline.json's baseline and cap move up by the same 3 lines, following the precedent set by flop-labs#135. Regression test in tests/http/test_notes.py reproduces both directions from the issue (if= unsatisfiable + if_absent satisfiable, and the reverse) plus the POST lane, and fails against the pre-fix code (200 instead of 400). Fixes flop-labs#290 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
japaneseml
force-pushed
the
fix/condition-if-and-if-absent
branch
from
August 27, 2026 00:37
2bb09c2 to
6d19086
Compare
Contributor
|
Duplicate of #307, which fixes the same issue (#290) with a smaller, more focused diff — this PR bundles unrelated refactors and touches Generated by Claude Code |
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.
The bug
_condition()returned on theif_absentbranch beforeif=was ever read,so a write sent with both (
?if=X&if_absent=1) silently droppedif=. Whenif=was the condition that could not hold, the request still answered 200instead of being refused — a caller relying on
if=for compare-and-set(task-state transitions per
/interop.md) had no way to know its conditionwas never checked.
The fix
The two forms are mutually exclusive by definition:
if_absentmeans thenote is not there,
if=means it's there holding exactly that value. Thereis no correct value to pick silently, so both are now read and sending both
together raises
StoreError, which the existing exception handler rendersas
400 {message}— the same shape every other input refusal already uses,so no new exception type or wiring was needed for this one call site.
core/app.pygrows 981 -> 984 code lines for the extra branch and raise;sz-baseline.json's baseline and cap move up by the same 3 lines, followingthe precedent set by #135.
Test (before/after)
New regression test in
tests/http/test_notes.py, covering both directionsplus the POST lane:
assert r.status_code == 400→AssertionError: assert 200 == 400(the exact issue: unsatisfiableif=silently dropped, notecreated anyway)
Full suite:
399 passed.Checks
Fixes #290
🤖 Generated with Claude Code