Repository navigation
fix(core): re-parenting doc upsert carries the whole subtree - #1378
Merged
Merged
Conversation
upsert_document rewrote only the document's own parent/path/depth when an existing slug got a new parent, leaving descendants under the old path (a later delete of the old parent cascaded onto the moved subtree). It now rewrites descendants with the same helper as move_document, refuses a move into the document's own subtree and a result deeper than MAX_DEPTH before writing anything. Fixes #1377 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
Every subtree query matched paths with LIKE '<path>/%' unescaped, so '_' and '%' in a stored path acted as wildcards: moving /my_doc/ also rewrote /myxdoc/... and deleting it removed the look-alike subtree. All path LIKE queries (move, delete, count/list descendants, re-parent rewrite, depth guard) now escape the prefix and use ESCAPE '\'. Found by CodeCora on #1378. Refs #1377 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The re-parenting cycle check used the escaped LIKE prefix as a string prefix, which never matched paths containing '_' or '%'. Use the raw directory form. Found by CodeCora on #1378. Refs #1377 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
What
Store::upsert_document(update branch): when the document'spathchanges (new parent, or no parent), rewrite thepath/depthof its whole subtree. The rewrite is the same helpermove_documentnow uses (rewrite_descendants, prefixsubstrreplace + depth delta; empty legacy paths are skipped as in fix(core): documents has_children, legacy-path move, tag rename dupes, empty index rebuild, recompute_importance #1375).MAX_DEPTH(10); the transaction rolls back untouched.move_documentshares the new helpers (subtree_selectors,rewrite_descendants); behaviour unchanged.Why
#1377: tree a → k → g, upsert
kunderbleftgat/a/k/g/. Delete, move and tree queries select subtrees bypath LIKE, so deletingawould then deletegalthough it had moved withk.Behaviour change
Re-parenting through
doc upsert(HTTP/MCP/CLI) now also moves descendants and can now fail with the two validation errors above (previously it silently corrupted paths). CORE docs area, derived-data fix, no wire shape change; noted for the cloud notice (#117).Testing
cargo fmt --check,cargo clippy --workspace --all-targetsclean;cargo test --workspacegreen (core 654); vecq-only core build green (651).Fixes #1377
🤖 Generated with Claude Code