Skip to content

fix: normalize identityref prefix aliases in must-statement xpath literals#241

Open
steiler wants to merge 1 commit into
mainfrom
fix/identityref-must-normalization
Open

fix: normalize identityref prefix aliases in must-statement xpath literals#241
steiler wants to merge 1 commit into
mainfrom
fix/identityref-must-normalization

Conversation

@steiler
Copy link
Copy Markdown
Collaborator

@steiler steiler commented Jun 1, 2026

Summary

  • getMustStatement in pkg/schema/leaf.go now calls normalizeXPathLiterals on each must expression before returning it. This rewrites quoted string literals of the form 'alias:IdentityName' where alias is a local import alias (not the module's own declared prefix) to 'declaredPrefix:IdentityName', using the yang.Entry module's import prefix map.
  • Adds normalizeXPathLiterals and normalizeIdentityrefLiteral helpers. Plain literals, unknown prefixes, and already-canonical prefixes are passed through unchanged (idempotent).
  • YANG test fixtures added in 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

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant