fix: normalize identityref prefix aliases in must-statement xpath literals#241
Open
steiler wants to merge 1 commit into
Open
fix: normalize identityref prefix aliases in must-statement xpath literals#241steiler wants to merge 1 commit into
steiler wants to merge 1 commit into
Conversation
…erals getMustStatement now calls normalizeXPathLiterals on each must expression before returning it. This rewrites quoted literals of the form 'alias:IdentityName' where alias is a local import alias (not the module's own declared prefix) to 'declaredPrefix:IdentityName', so that xpath evaluation at runtime sees a consistent, canonical prefix regardless of how the consuming module chose to import the identity module. Adds normalizeXPathLiterals and normalizeIdentityrefLiteral helpers. Plain literals, unknown prefixes, and already-canonical prefixes are passed through unchanged (idempotent). Regression tests: TestGetMustStatement_NormalizesAlias, TestGetMustStatement_AlreadyDeclaredPrefix, TestGetMustStatement_PlainLiteralUnchanged, TestGetMustStatement_UnknownPrefixUnchanged. YANG fixtures in pkg/schema/testdata/must-alias/. Companion fix in data-server: sdcio/data-server fix/identityref-leafref-normalization Co-authored-by: Cursor <cursoragent@cursor.com>
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
getMustStatementinpkg/schema/leaf.gonow callsnormalizeXPathLiteralson each must expression before returning it. This rewrites quoted string literals of the form'alias:IdentityName'wherealiasis a local import alias (not the module's own declared prefix) to'declaredPrefix:IdentityName', using theyang.Entrymodule's import prefix map.normalizeXPathLiteralsandnormalizeIdentityrefLiteralhelpers. Plain literals, unknown prefixes, and already-canonical prefixes are passed through unchanged (idempotent).pkg/schema/testdata/must-alias/covering: non-standard alias, correct prefix (idempotent), plain literal, and unknown prefix cases.This is a compile-time-only change. Existing compiled schemas need a schema reload to pick up the rewritten must statements.
Companion PR
data-server (JSON importer normalisation + leafref + Navigate fixes):
→ sdcio/data-server#444