[YANGTOOLS-816] Deviate replace using a non-prefixed user-defined-type fails Created: 04/Oct/17  Updated: 10/Apr/22  Resolved: 17/Oct/17

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Igor Foltin Assignee: Igor Foltin
Resolution: Duplicate 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
duplicates YANGTOOLS-815 Deviate replace using a user-defined-... Verified
External issue ID: 9243

 Description   

The problem looks like this:

We want to replace a type substatement with a non-prefixed user-defined type using deviate replace. YANG statement parser throws an exception as it cannot find and resolve the type in the new statement context.



 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; }

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

{ type new-type; }

}

typedef new-type {
type int32

{ range 10..15; }

}
}

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

leaf my-leaf

{ type string; }

}

Parsing this model results in the following exception:

Caused by: org.opendaylight.yangtools.yang.parser.spi.source.SourceException: Type '(imp-ns?revision=1970-01-01)new-type' not found [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.stmt.rfc6020.TypeStatementImpl$Definition.createEffective(TypeStatementImpl.java:169)
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

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