Skip to content

fix(rest): let If-Match "0" write the first user-settings version - #443

Closed
angela-helios wants to merge 1 commit into
mainfrom
fix/442-settings-if-match-zero
Closed

fix(rest): let If-Match "0" write the first user-settings version#443
angela-helios wants to merge 1 commit into
mainfrom
fix/442-settings-if-match-zero

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Closes #442

GET /_user/settings serves the empty document as a real representation — {} with ETag: "0" — but check_if_match mapped version 0 to "no current representation", so the exact validator the GET handed out could never satisfy a conditional write. A fresh user's read-then-conditional-write (saved-queries.js's roaming recents do exactly this) retried into 412 forever. It went unnoticed because nav.js used to create the document with an unconditional PATCH on the first toggle; #438 removes nav.js, and PR #440's CI then failed deterministically on queries.spec.ts › a run is recorded under the Recent disclosure — the trace shows the three PATCH → 412 with If-Match: "0" against a fresh database.

Concrete tag lists now evaluate against the version number including 0, so "0" round-trips; If-Match: * keeps requiring an actually stored document. No storage changes: all four backends already treat an expected version 0 as insert-if-absent.

Tests: fresh-store round-trip (GET etag "0" → conditional PATCH creates version 1 → "0" is then genuinely stale again) and the *-still-requires-existence guard. 25/25 in user_settings.

Note for #440: its e2e Recent failure is this bug surfacing; once this merges, #440 rebases green.

GET serves the empty settings document as a real representation ({} with
ETag "0"), but check_if_match mapped version 0 to 'no representation',
so the validator the GET handed out could never satisfy a conditional
write: a fresh user's read-then-conditional-write 412'd forever. Concrete
tag lists now evaluate against the version number including 0; If-Match: *
keeps requiring an actually stored document. The storage layer already
treated an expected version 0 as insert-if-absent on all four backends.

Closes #442
@claude

claude Bot commented Jul 29, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@angela-helios

Copy link
Copy Markdown
Contributor Author

Folded into #440 per review flow — its branch already carries this commit (b3815439e, merged as 5a7ea5a32), so one PR delivers the rail and the settings fix it uncovered. Closing without merge.

@angela-helios
angela-helios deleted the fix/442-settings-if-match-zero branch July 30, 2026 02:19
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.

user-settings: a fresh user can never write conditionally — If-Match "0" is rejected against the ETag the GET itself served

2 participants