[YANGTOOLS-1428] Missing failedSource in SchemaResolutionException Created: 14/Apr/22  Updated: 03/May/22  Resolved: 03/May/22

Status: Resolved
Project: yangtools
Component/s: parser
Affects Version/s: 7.0.15, 8.0.3
Fix Version/s: 9.0.0, 7.0.16, 8.0.4

Type: Bug Priority: Medium
Reporter: Sangwook Ha Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to YANGTOOLS-1085 Fully validate XPath expressions Resolved

 Description   

SchemaResolutionException thrown from AssembleSources does not have failedSource even though the information is available in SomeModifiersUnresolvedException wrapped in YangParserException, which in turn included in SchemaResolutionException.

For example, the following two data modules does not compile successfully, as expected, because the target path of the deviation statement is invalid.

orig.yang

module orig {
  namespace "urn:orig";
  prefix orig;

  container foo {
    leaf bar {
      type string;
    }
  }
}

deviate.yang

module deviate {
  namespace "urn:deviate";
  prefix dev;

  import orig {
    prefix orig;
  }

  deviation "/orig:foo/orig:bar/orig:baz" {
    deviate not-supported;
  }
}

When this error occurs during NETCONF mounting process, the whole mounting process fails because NETCONF does not find the failed source information:

2022-04-14T14:17:30,752 | ERROR | remote-connector-processing-executor-11 | BuildGlobalContext               | 341 - org.opendaylight.yangtools.yang-parser-reactor - 8.0.3 | Failed to parse YANG from source SourceSpecificContext [source=YangStatementStreamSource{identifier=RevisionSourceIdentifier [name=deviate]}, current=EFFECTIVE_MODEL, finished=FULL_DECLARATION]: Deviation target 'Absolute{qnames=[(urn:orig)foo, bar, baz]}' not found. [at cache/ncserver/deviate.yang:9:3]
2022-04-14T14:17:30,753 | DEBUG | remote-connector-processing-executor-11 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Unable to map any source identifiers to a capability reported by device : []
2022-04-14T14:17:30,754 | WARN  | remote-connector-processing-executor-11 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Unable to build schema context, unsatisfied imports null, will reattempt with resolved only
2022-04-14T14:17:30,754 | DEBUG | remote-connector-processing-executor-11 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Unable to build schema context, unsatisfied imports {}, will reattempt with resolved only
org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException: Failed to resolve required models, failed source: null, resolved sources: [], unsatisfied imports: {}
	at org.opendaylight.yangtools.yang.parser.repo.AssembleSources.apply(AssembleSources.java:93) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.AssembleSources.apply(AssembleSources.java:38) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:221) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:208) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:122) ~[bundleFile:?]
	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:761) ~[bundleFile:?]
	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.addListener(FluentFuture.java:114) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture.create(AbstractTransformFuture.java:43) ~[bundleFile:?]
	at com.google.common.util.concurrent.Futures.transformAsync(Futures.java:456) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.SharedEffectiveModelContextFactory.resolveEntry(SharedEffectiveModelContextFactory.java:194) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.SharedEffectiveModelContextFactory.computeModel(SharedEffectiveModelContextFactory.java:176) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.SharedEffectiveModelContextFactory.createEffectiveModel(SharedEffectiveModelContextFactory.java:134) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.SharedEffectiveModelContextFactory.createEffectiveModelContext(SharedEffectiveModelContextFactory.java:129) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.trySetupSchema(NetconfDevice.java:510) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.startResolution(NetconfDevice.java:463) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.assembleSchemaContext(NetconfDevice.java:304) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.lambda$onRemoteSessionUp$0(NetconfDevice.java:175) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:221) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:208) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:122) [bundleFile:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.opendaylight.yangtools.yang.parser.api.YangParserException: Failed to assemble sources
	at org.opendaylight.yangtools.yang.parser.impl.DefaultYangParser.decodeReactorException(DefaultYangParser.java:104) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.impl.DefaultYangParser.buildEffectiveModel(DefaultYangParser.java:98) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.AssembleSources.apply(AssembleSources.java:91) ~[bundleFile:?]
	... 24 more
Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException: Some of EFFECTIVE_MODEL modifiers for statements were not resolved.
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:336) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.completePhaseActions(BuildGlobalContext.java:398) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.executePhases(BuildGlobalContext.java:199) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:210) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:224) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.impl.DefaultYangParser.buildEffectiveModel(DefaultYangParser.java:96) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.AssembleSources.apply(AssembleSources.java:91) ~[bundleFile:?]
	... 24 more
Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Deviation target 'Absolute{qnames=[(urn:orig)foo, bar, baz]}' not found. [at cache/ncserver/deviate.yang:9:3]
	at org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviate.AbstractDeviateStatementSupport$1.prerequisiteFailed(AbstractDeviateStatementSupport.java:175) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.ModifierImpl.failModifier(ModifierImpl.java:87) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:383) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:307) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.completePhaseActions(BuildGlobalContext.java:398) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.executePhases(BuildGlobalContext.java:199) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:210) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:224) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.impl.DefaultYangParser.buildEffectiveModel(DefaultYangParser.java:96) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.parser.repo.AssembleSources.apply(AssembleSources.java:91) ~[bundleFile:?]
	... 24 more
2022-04-14T14:17:30,780 | DEBUG | remote-connector-processing-executor-11 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: no more sources for schema context
2022-04-14T14:17:30,782 | WARN  | remote-connector-processing-executor-12 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Unexpected error resolving device sources
org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$EmptySchemaContextException: RemoteDevice{ncserver}: No more sources for schema context
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.trySetupSchema(NetconfDevice.java:514) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.onFailure(NetconfDevice.java:503) ~[bundleFile:?]
	at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1124) ~[bundleFile:?]
	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:761) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.addListener(AbstractFuture.java:136) ~[bundleFile:?]
	at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1105) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.trySetupSchema(NetconfDevice.java:510) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.startResolution(NetconfDevice.java:463) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.assembleSchemaContext(NetconfDevice.java:304) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.lambda$onRemoteSessionUp$0(NetconfDevice.java:175) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:221) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:208) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:122) [bundleFile:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2022-04-14T14:17:30,784 | ERROR | remote-connector-processing-executor-12 | NetconfDevice                    | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Initialization in sal failed, disconnecting from device
org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$EmptySchemaContextException: RemoteDevice{ncserver}: No more sources for schema context
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.trySetupSchema(NetconfDevice.java:514) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.onFailure(NetconfDevice.java:503) ~[bundleFile:?]
	at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1124) ~[bundleFile:?]
	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:761) [bundleFile:?]
	at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.addListener(AbstractFuture.java:136) ~[bundleFile:?]
	at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1105) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.trySetupSchema(NetconfDevice.java:510) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice$SchemaSetup.startResolution(NetconfDevice.java:463) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.assembleSchemaContext(NetconfDevice.java:304) ~[bundleFile:?]
	at org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.lambda$onRemoteSessionUp$0(NetconfDevice.java:175) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:221) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:208) ~[bundleFile:?]
	at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:122) [bundleFile:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2022-04-14T14:17:30,787 | WARN  | remote-connector-processing-executor-12 | NetconfDeviceCommunicator        | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | RemoteDevice{ncserver}: Session terminated Session closed
2022-04-14T14:17:30,787 | DEBUG | remote-connector-processing-executor-12 | NetconfDeviceCommunicator        | 282 - org.opendaylight.netconf.sal-netconf-connector - 3.0.1.SNAPSHOT | Tearing down Session closed
2022-04-14T14:17:30,788 | DEBUG | globalWorkerGroup-3-1 | AbstractNetconfSession           | 277 - org.opendaylight.netconf.netty-util - 3.0.1.SNAPSHOT | Channel [id: 0xc87fcd5a] inactive.
2022-04-14T14:17:30,788 | DEBUG | globalWorkerGroup-3-1 | AbstractNetconfSession           | 277 - org.opendaylight.netconf.netty-util - 3.0.1.SNAPSHOT | Session NetconfClientSession{sessionId=3, channel=[id: 0xc87fcd5a]} end of input detected while session was in state initialized
2022-04-14T14:17:30,788 | DEBUG | globalWorkerGroup-3-1 | NetconfClientSessionImpl         | 284 - org.opendaylight.netconf.shaded-sshd - 3.0.1.SNAPSHOT | close(NetconfClientSessionImpl[netconf@/10.100.18.43:830]) Closing gracefully


 Comments   
Comment by Sangwook Ha [ 14/Apr/22 ]

This is a regression - e.g. with Magnesium the failed source information is available and so NETCONF can proceed to complete mounting process with the invalid module excluded.
This commit appears to have changed the behavior:
https://github.com/opendaylight/yangtools/commit/b26aa45184c4a32373de46112c90d7570c092e18#diff-23d66446ef80f73d5aed2d6491f77fcc40bc2ef9fef792a58c108e915276f518L240

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