[YANGTOOLS-815] Deviate replace using a user-defined-type fails Created: 04/Oct/17  Updated: 10/Apr/22  Resolved: 20/Nov/17

Status: Verified
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.0

Type: Bug
Reporter: Igor Foltin Assignee: Igor Foltin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Duplicate
is duplicated by YANGTOOLS-816 Deviate replace using a non-prefixed ... Resolved
is duplicated by YANGTOOLS-818 Typedef not resolved properly in devi... Resolved
External issue ID: 9242

 Description   

The problem looks like this:

We want to replace a type substatement with a prefixed user-defined type using deviate replace. YANG statement parser throws an exception as it cannot resolve the QNameModule of the prefixed type in the new statement context which does not recognize the prefix.



 Comments   
Comment by Igor Foltin [ 13/Oct/17 ]

YANG example which can be used to reproduce the bug:

module root-module {
namespace rm-ns;
prefix rm;

import imp-module

{ prefix im; }

import imp-module-2

{ prefix im2; }

deviation "/im:my-leaf" {
deviate replace

{ type im2:new-type; }

}
}

module imp-module {
namespace imp-ns;
prefix imp;

leaf my-leaf

{ type string; }

}

module imp-module-2 {
namespace imp2-ns;
prefix imp2;

typedef new-type {
type string

{ length 10..15; }

}
}

Parsing this model results in the following exception:

Caused by: org.opendaylight.yangtools.yang.parser.spi.source.SourceException: Cannot resolve QNameModule for 'im2:new-type' [at /home/igor/projects/yangtools/yang/yang-parser-impl/target/test-classes/deviation-resolution-test/temporary/root-module.yang:15:12]
at org.opendaylight.yangtools.yang.parser.spi.source.SourceException.throwIf(SourceException.java:97)
at org.opendaylight.yangtools.yang.parser.spi.source.SourceException.throwIfNull(SourceException.java:114)
at org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.qnameFromArgument(StmtContextUtils.java:509)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeStatementImpl$Definition.createEffective(TypeStatementImpl.java:167)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeStatementImpl$Definition.createEffective(TypeStatementImpl.java:88)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:457)
at com.google.common.collect.Iterators$5.transform(Iterators.java:757)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:257)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.<init>(EffectiveStatementBase.java:55)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase.<init>(DeclaredEffectiveStatementBase.java:31)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode.<init>(AbstractEffectiveDocumentedNode.java:30)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveSchemaNode.<init>(AbstractEffectiveSchemaNode.java:28)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDataSchemaNode.<init>(AbstractEffectiveDataSchemaNode.java:28)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafEffectiveStatementImpl.<init>(LeafEffectiveStatementImpl.java:34)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.LeafStatementImpl$Definition.createEffective(LeafStatementImpl.java:81)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:457)
at com.google.common.collect.Iterators$5.transform(Iterators.java:757)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:257)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.<init>(EffectiveStatementBase.java:55)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase.<init>(DeclaredEffectiveStatementBase.java:31)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode.<init>(AbstractEffectiveDocumentedNode.java:30)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveModule.<init>(AbstractEffectiveModule.java:89)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl.<init>(ModuleEffectiveStatementImpl.java:23)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ModuleStatementSupport.createEffective(ModuleStatementSupport.java:101)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase.buildEffective(StatementContextBase.java:457)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.transformEffective(BuildGlobalContext.java:269)
... 34 more

Comment by Igor Foltin [ 17/Oct/17 ]

Fix on master: https://git.opendaylight.org/gerrit/#/c/64406/

Comment by Igor Foltin [ 24/Oct/17 ]

nitrogen fix: https://git.opendaylight.org/gerrit/#/c/64644/
carbon fix: https://git.opendaylight.org/gerrit/#/c/64647/

Comment by Peter Verthez [ 25/Oct/17 ]

Should the Fix Version field of the ticket also contain the respective nitrogen and carbon releases (SR1 and SR3 I assume)? I see also that the Resolution state has not changed from "unresolved".

Comment by Thanh Ha (zxiiro) [ 25/Oct/17 ]

Please ignore this comment.

Generated at Wed Feb 07 20:54:23 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.