[YANGTOOLS-1485] Fail to process deviation of augmented node without feature support Created: 07/Feb/23 Updated: 20/Mar/23 Resolved: 13/Mar/23 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | parser |
| Affects Version/s: | 8.0.9, 9.0.6, 10.0.3 |
| Fix Version/s: | 11.0.0, 8.0.10, 9.0.7, 10.0.5 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Sangwook Ha | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Parsing of YANG models fails if a deviation statement targets a node conditionally augmented based on a feature and the feature is not supported. In the following example with two modules, foo & bar, parsing fails if foo-feature is not supported. foo.yang module foo {
namespace "urn:foo";
prefix "foo";
feature foo-feature;
container foo {
}
augment /foo:foo {
if-feature foo-feature;
leaf foo-leaf {
type string;
}
}
}
bar.yang module bar {
namespace "urn:bar";
prefix "bar";
import foo {
prefix foo;
}
deviation /foo:foo/foo:foo-leaf {
deviate not-supported;
}
}
Parsing fails after trying to find the deviation target foo-leaf: Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Deviation target 'Absolute{qnames=[(urn:foo)foo, foo-leaf]}' not found. [at /volumes/OpenDaylight/yangtools/parser/yang-parser-rfc7950/target/test-classes/bugs/YT1485/augment/bar.yang:9:3]
at org.opendaylight.yangtools.yang.parser.rfc7950@10.0.4-SNAPSHOT/org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviate.AbstractDeviateStatementSupport$1.prerequisiteFailed(AbstractDeviateStatementSupport.java:167)
at org.opendaylight.yangtools.yang.parser.reactor@10.0.4-SNAPSHOT/org.opendaylight.yangtools.yang.parser.stmt.reactor.ModifierImpl.failModifier(ModifierImpl.java:86)
at org.opendaylight.yangtools.yang.parser.reactor@10.0.4-SNAPSHOT/org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:375)
at org.opendaylight.yangtools.yang.parser.reactor@10.0.4-SNAPSHOT/org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:307)
... 80 more
|
| Comments |
| Comment by Robert Varga [ 14/Feb/23 ] |
|
This boils down to order of evaluation. The deviation hooks up into schema tree namespace, but AbstractPathRequisite.namespaceItemAdded() executes as soon as /foo:foo is added. This results in it calling isSupportedByFeatures() before the if-feature statements has a chance of being added, and thus we do not report the prerequisiteUnavailable(), but end up reporting prerequisiteFailed(). Fixing this requires augmenting callers to make sure they can work with if we require FULL_DECLARATION along the entire tree and if they do perform another level of indirection, when we first require /foo:foo to complete FULL_DECLARATION before evaluating feature support. |
| Comment by Robert Varga [ 13/Mar/23 ] |
|
Right, so the only way we are using this is for EFFECTIVE_MODEL, hence can lock this use down and add a requirement on FULL_DECLARATION. |
| Comment by Robert Varga [ 13/Mar/23 ] |
|
Well, actually this is a tad simpler: augmentations need to propagate their children as long as the target is found. |