fix(yang-push): resolve xpath-filter target modules by prefix - #43
Open
rodonile wants to merge 2 commits into
Open
fix(yang-push): resolve xpath-filter target modules by prefix#43rodonile wants to merge 2 commits into
rodonile wants to merge 2 commits into
Conversation
Fetching a YANG Library by subscription id failed for devices that send an inline datastore-xpath-filter without xmlns bindings (e.g. Cisco IOS-XR), because module resolution only looked at declared namespace prefixes. The target module was silently dropped and every subsequent notification failed validation. Resolve xpath-filter modules per the RFC 8641 XPath context: use a declared xmlns binding when present (e.g. Huawei), otherwise treat the path prefix as the YANG module name (e.g. Cisco IOS-XR). Both are conformant. Subtree and stream filters keep namespace-based lookup. An empty resolution result is now a hard error instead of silently caching an incomplete library, and errors are now typed instead of generic IO errors. Add unit tests covering the two resolution cases, and extra trace-level logging for debugging.
There was a problem hiding this comment.
Pull request overview
Fixes YANG-Push cache fallback by resolving inline XPath prefixes against device YANG libraries.
Changes:
- Adds namespace and module-name prefix resolution.
- Rejects empty or unresolved module sets.
- Adds diagnostics and resolution tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/yang-push/src/cache/storage.rs |
Adds resolution-specific errors. |
crates/yang-push/src/cache/fetcher.rs |
Implements target-module resolution. |
crates/netconf-proto/src/yang_push/tests.rs |
Tests XPath prefix extraction. |
crates/netconf-proto/src/yang_push/filters.rs |
Exposes path prefixes. |
crates/netconf-proto/src/xml_utils.rs |
Shares XPath prefix parsing. |
crates/netconf-proto/src/client.rs |
Adds NETCONF diagnostics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The Cisco-style xpath prefix fallback (prefix == module name) resolved modules via YangLibrary::find_module, which searches every module set in the library regardless of datastore. A module name can be pinned at different revisions in different module sets (RFC 8525), so an unscoped lookup could silently fetch and cache the wrong revision for a subscription's target datastore. Add YangLibrary::find_module_by_datastore_and_name, mirroring the existing namespace-scoped lookup, and use it for the prefix-as-name fallback so both resolution paths are scoped consistently. Add a regression test with the same module name at two revisions in two datastores.
rodonile
force-pushed
the
xpath-namespace
branch
from
August 21, 2026 14:31
282892e to
7d62119
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (1)
crates/netconf-proto/src/yang_push/tests.rs:803
- The Huawei-style XPath example has a likely typo in the path (
devm:chassiss). It doesn’t affect the prefix-extraction assertion, but it makes the test fixture harder to read and can confuse future debugging (it looks like it’s meant to bedevm:chassis).
namespaces: Box::new([
("devm".into(), "urn:huawei:yang:huawei-devm".into()),
("driver".into(), "urn:huawei:yang:huawei-driver".into()),
]),
path: "/devm:devm/devm:chassiss/devm:chassis/driver:power-supply-attribute".into(),
};
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
YANG-Push cache misses that fall back to fetch-by-subscription-id failed for
devices sending an inline
datastore-xpath-filterwithoutxmlnsprefixbindings (e.g. Cisco IOS-XR, where the path prefix is the YANG module name,
like
Cisco-IOS-XR-procmem-oper:...). Module resolution only consulteddeclared namespace prefixes, so the subscription's own target module was
never considered for the NETCONF
get-schemaset.Devices that declare
xmlnsbindings on their filters (e.g. Huawei) wereunaffected.
Root cause
Per RFC 8641, the XPath context for
datastore-xpath-filteris built bycombining two prefix-resolution mechanisms:
server implements (no
xmlnsneeded) — this is what Cisco IOS-XR uses.xmlnsdeclarations on the leaf element, which override onconflict — this is what Huawei uses.
The fetcher only supported mechanism (2), so inline Cisco filters resolved to
zero modules and the fetch "succeeded" with an incomplete library.
Changes
declared
xmlnsbinding first, then fall back to treating the path prefixas the YANG module name. Subtree and stream filters keep namespace-based
lookup.
that keeps failing validation forever.
fallback now uses a datastore-scoped module lookup (mirroring the
namespace-based one) instead of an unscoped search, so it can't return a
module revision pinned in an unrelated datastore/module-set.