Repository navigation
Conditional writes (ETag / If-Match) so two clients can't silently overwrite each other #379
ErikEvenson
started this conversation in
Ideas
Replies: 1 comment
|
We already have |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'd like to float a small feature before writing any code, per CONTRIBUTING.
The problem. A
PUT(orPATCH,POSTappend,DELETE) on a note always succeeds against whatever is there now. If two clients read a note, and both then write their edited copy, the second write silently discards the first. With one person typing in Obsidian that rarely matters. But since the MCP server, a vault often has several automated writers at once: an agent, a script, a second session, the user editing by hand. That's the setup where this bites, and there's no way for a careful client to protect itself today, because it can't ask "write this only if the note is still the version I read".The proposal: standard HTTP conditional requests, opt-in and backward compatible.
GET /vault/{path}(and the other single-note reads) returns anETagfor the file's current content, for example a hash of the bytes or of mtime plus size.If-Match: <etag>. If the note has changed since that version, the server answers 412 Precondition Failed and writes nothing. That's the status the API already uses for PATCH target preconditions.PUTacceptsIf-None-Match: *to mean "create only; fail if the note exists".expected_etagargument that maps toIf-Match.What I'd plan to include, if you're open to it:
Questions for you:
PUT,PATCH,POSTandDELETEon/vault/and the periodic-note equivalents.Happy to adjust the scope to whatever fits the project best.
A note on how this was put together: I researched and drafted this proposal with Claude, an AI assistant, and any code I contribute would be AI-assisted too. I review everything myself, and I'd follow the workflow in your AGENTS.md: failing test first, small commits that each leave main green.
All reactions