Repository navigation
fix(schema): remove map paths cleanly, including maps under nested paths (backport to 8.x) - #16625
Merged
vkarpov15 merged 2 commits intoOct 21, 2026
Conversation
(cherry picked from commit 1be9b7b)
Schema#remove() walks the subpaths of a nested branch and calls _deletePath on each. A map registers its values under `<path>.$*`, which has no branch of its own in the tree, and by the time that subpath is reached its parent has already been deleted in the same pass, so the walk lands on undefined and the delete throws. _deletePath now stops when a piece along the way is missing, and the nested branch filters mapPaths the way the flat branch already does, so the schema stops answering pathType() for a path it removed. Follow up to Automattic#16457, which covered the flat case. (cherry picked from commit 2095a35)
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.
Summary
Backport of #16457 and its follow-up #16461 to 8.x. Both fix
Schema#remove()for map paths, in the same function, so they're backported together.On 8.x:
<path>.$*) behind, so the schema keeps answeringpathType()and casting queries for a path it no longer has (fix(schema): drop the map values subpath when removing a map path #16457)._deletePathwalks to<map>.$*after its parent was already deleted in the same pass (fix(schema): remove a map that lives under a nested path #16461):Both commits cherry-pick cleanly onto 8.x, in upstream order (
git cherry-pick -x 1be9b7b5f 2095a35c5), no changes needed.Examples
The tests added in #16457 and #16461 are included. On current 8.x both fail; with these changes
test/schema.test.jspasses (213 tests).Ran locally on Node 24:
test/schema.test.js, the fullnpm testsuite (4057 passing; the one failure, anundoReset()test, hit its 2s timeout during the full run on this machine and passes when run alone, on plain 8.x as well), and ESLint on the changed files.