Repository navigation
fix: make registerTag symmetric without mutating the shared nameMap - #548
Merged
awatson1978 merged 1 commit intoSep 30, 2026
Merged
Conversation
registerTag() now also indexes its entry by keyword in a registry-local name index, and static denaturalizeDataset consults that index on a nameMap miss. Registered custom names round-trip through naturalize -> denaturalize, and reading a dataset never writes into the shared DicomMetaDictionary.nameMap, so no custom entry can leak from one dataset into later naturalizations. Review finding 32 from the PR #512 review map; unskips the #215 asymmetric-registration known-gap test and adds a nameMap-isolation guard in test/issues/issue388-private-tags.test.js. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Sep 30, 2026
|
🎉 This PR is included in version 1.0.0-beta.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This was referenced Oct 30, 2026
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.
registerTag()is now symmetric — a registered custom keyword denaturalizes back to its tag — and the symmetry comes from the registry itself, never from mutating the sharednameMap.The situation before this PR:
registerTag("00091001", { name: "AcmePrivateValue", vr: "LO" })taught the dictionary a custom keyword, sonaturalizeDatasethappily emitteddataset.AcmePrivateValue. ButDicomMetaDictionary.nameMap— the reverse index thatdenaturalizeDatasetuses — is built once from the standard dictionary and never learns registered names. So the renamed element was dropped on the way back with an "Unknown name in dataset" warning: registration worked in one direction only.The PR #512 development branch closed this gap the wrong way, and that's review finding 32: its naturalizer wrote registered entries into the static
DicomMetaDictionary.nameMapas a side effect of reading a dataset. WhetherdenaturalizeDatasetsucceeded for a given input then depended on whether some earlier, unrelated call had happened to naturalize a dataset containing that tag — tests that pass in a full suite run and fail alone, custom entries leaking into every later naturalization in the process, and no way to undo it. The review's guidance was to put the global change where a caller expects one: inregisterTag()itself.That's what this does.
registerTag()now also indexes the entry by its keyword in a registry-local name index (oneMap.setper registration — the lazynameMapbuild is untouched, nothing is rebuilt per call), and staticdenaturalizeDatasetconsults that index only on anameMapmiss. Reading a dataset mutates nothing; an explicitly passed customnameMap(the instance path) stays authoritative.Two tests pin it in
test/issues/issue388-private-tags.test.js: the #215 asymmetric-registration known-gap skip, now green and unskipped, and a new guard asserting that a naturalize → denaturalize pass over a dataset with a registered tag leavesDicomMetaDictionary.nameMapbyte-for-byte alone — the exact leak from review finding 32 of the PR #512 review map. For the record, the mutation defect itself never existed onmaster(0.52): master hasregisterTag()with the same one-way asymmetry, but its naturalizer never wrote intonameMap— the leak was new code in the #512 development branch.🤖 Generated with Claude Code