Repository navigation
fix: refuse when both if and if_absent are present - #386
sipalingnode wants to merge 1 commit into
Conversation
_condition() silently dropped if= when if_absent was also present, letting an unsatisfiable condition pass as 200. Now raises ConditionConflict (rendered as 400) so callers learn the conflict rather than getting a silently wrong answer. Closes flop-labs#290
|
One lane-ordering edge looks worth pinning before merge: the new conflict check runs after So the same signed request shape ( That seems especially visible because this nonce is a server-written ownership counter shared across signers. The existing HEAD regression in Would it make sense to parse/validate
That would also make the GET/POST conflict behavior match at the nonce boundary. I don't think this changes the intended "a burnt nonce is not refunded if the write behind it then fails" rule; this is about rejecting the contradictory request shape before spending the nonce, analogous to the other pre-burn gates. |
luch91
left a comment
There was a problem hiding this comment.
The conflict behavior is coherent, but this PR duplicates the already-open implementation of issue #290 in PR #307 (same if + if_absent rejection and call-site handling). Its _condition() logic also predates the active case-insensitive falsy handling in PR #416, so merging both independently would require conflict resolution and could leave inconsistent condition semantics. Please coordinate with or rebase onto the authoritative change rather than landing a duplicate implementation. The visible check list currently reports only skipped [code]smith.
|
@sipalingnode — you and #307 were each asked to stand down in favour of the other, four hours apart, so neither of you can move without ignoring a review. I filed #290, which both of these implement, so I have written up the comparison there rather than leaving it circular: #307 (comment) Short version, so you do not have to go and read it to find out you lost: I said there, and mean it here: raising from If |
|
I verified the current head 87e8326: |
|
I checked the ordering claim against three trees, because it bears on which branch lands and I filed the issue both of these implement. The finding is right, and it is not this branch's. The GET lane burns before it evaluates the condition and the POST lane does the opposite, in all three. So the ordering is upstream's and predates both pull requests. (main moved to aa7017f while I was writing this -- b7ad42e and aa7017f -- and the file is byte-identical across the move, same line numbers.) What is new is that it now costs something. On So this applies to #307 exactly as it applies here — @alpertungax1, this is worth reading before that branch merges either. Whichever one lands needs the fix; neither is more at fault, and I would rather say so than let it look like a reason to prefer one. The smaller change is to evaluate the condition before burning on the GET lane, which also puts the two lanes in the same order and makes the parity test able to say so. Moving the burn later is the direction that fails closed: a refused request should cost nothing. For the regression, the thing worth pinning is the counter rather than the status code — a test that only asserts 400 passes whether or not the nonce moved: and the same request over POST, so the two lanes are asserted equal rather than each asserted alone. I cannot run the suite to confirm any of this — the store is |
|
Closing as shipped. #533 (0.11.0) refuses Duplicate closed alongside: #307. Generated by Claude Code |
What this fixes
_condition()silently droppedif=whenif_absentwas also present, letting an unsatisfiable condition pass as 200. Now raisesConditionConflict(rendered as 400) so callers learn the conflict rather than getting a silently wrong answer.Closes #290
Changes
ConditionConflictexception class_condition()now checks for both conditions and raises instead of silently picking onenote_write,note_write_signed,note_post) catch the exception and return 400Tests