feat: Prevent implicit document creation via If-Match header#105
Merged
Conversation
karlpauls
marked this pull request as draft
November 14, 2025 18:37
LCOV of commit
|
auniverseaway
self-requested a review
November 19, 2025 05:27
auniverseaway
approved these changes
Nov 19, 2025
bosschaert
reviewed
Nov 20, 2025
bosschaert
reviewed
Nov 20, 2025
karlpauls
marked this pull request as ready for review
November 21, 2025 10:49
bosschaert
approved these changes
Nov 21, 2025
adobe-bot
pushed a commit
that referenced
this pull request
Dec 8, 2025
# 1.0.0 (2025-12-08) ### Bug Fixes * add check for shared secret ([#108](#108)) ([a79731f](a79731f)) * add span to known HTML tags ([#101](#101)) ([fbf016d](fbf016d)) * do not empty document if error ([#90](#90)) ([a406add](a406add)) * encode HTML brackets ([#100](#100)) ([6c5b5fd](6c5b5fd)) * encode HTML brackets ([#74](#74)) ([015163e](015163e)) * keep content if no main found in html ([#85](#85)) ([9fd25ac](9fd25ac)) * null doc crashes aem2doc ([#84](#84)) ([6197114](6197114)) * ommit stacktraces in error map for non-dev ([#110](#110)) ([1f896ac](1f896ac)) * remove html comments ([#68](#68)) ([cf05aae](cf05aae)) ### Features * disable stack traces on production ([#109](#109)) ([79c40bd](79c40bd)) * Prevent implicit document creation via If-Match header ([#105](#105)) ([b33ae65](b33ae65))
adobe-bot
pushed a commit
that referenced
this pull request
Dec 8, 2025
# 1.0.0 (2025-12-08) ### Bug Fixes * add check for shared secret ([#108](#108)) ([a79731f](a79731f)) * add span to known HTML tags ([#101](#101)) ([fbf016d](fbf016d)) * do not empty document if error ([#90](#90)) ([a406add](a406add)) * encode HTML brackets ([#100](#100)) ([6c5b5fd](6c5b5fd)) * encode HTML brackets ([#74](#74)) ([015163e](015163e)) * keep content if no main found in html ([#85](#85)) ([9fd25ac](9fd25ac)) * null doc crashes aem2doc ([#84](#84)) ([6197114](6197114)) * ommit stacktraces in error map for non-dev ([#110](#110)) ([1f896ac](1f896ac)) * remove html comments ([#68](#68)) ([cf05aae](cf05aae)) * trigger release ([ca061d4](ca061d4)) ### Features * disable stack traces on production ([#109](#109)) ([79c40bd](79c40bd)) * Prevent implicit document creation via If-Match header ([#105](#105)) ([b33ae65](b33ae65))
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.
Problem
Currently, da-collab can implicitly create documents in da-admin through the first PUT request. This creates issues when documents are deleted or never existed - we end up recreating them
unintentionally.
Solution
This PR enforces explicit document existence checks at two levels:
1. Authorization Phase
Reject connections to non-existent documents immediately. Previously, 404 responses during the HEAD request were allowed (anticipating document creation). Now they fail fast at the edge.
2. Write Phase
Added
If-Match: *header to all PUT requests. This tells da-admin "only write if document exists" - the server returns 412 if it doesn't.3. Cleanup on Conflict
When we get 412 (document was deleted), we now:
storage.deleteAll()4. Error Propagation
persistence.getnow throws on 404 instead of returning null. This catches the edge case where a document is deleted between authorization and content fetch.Error details are stored in the Yjs document's error map before connections close, so clients receive the error via the sync protocol.
Deployment
The header needs to be recognized and 412 returned when documents don't exist. See adobe/da-admin#187