[MDSAL-517] Target type not yet generated with augmenting action inputs Created: 27/Feb/20  Updated: 29/Feb/20  Resolved: 29/Feb/20

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: 6.0.0, 5.0.10, 4.0.12

Type: Bug Priority: Medium
Reporter: Miroslav Kovac Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

 

The following two models:

module a {
  yang-version 1.1;
  namespace "a";
  prefix a;

  grouping a-grp {
    action a-act {
      input {
        leaf a-action-input-leaf {
          type empty;
        }
      }
    }
  }
  container a-cont {
    uses a:a-grp;
  }
}

module b {
  yang-version 1.1;
  namespace "b";
  prefix b;

  import a {
    prefix a;
  }

  augment "/a:a-cont/a:a-act/a:input" {
   description
      "An augmentation of a action input of module a";
    leaf b-aug-leaf {
      type empty;
    }
  }
}

result in AbstractTypeGenerator.augmentationToGenTypes() failing:

[ERROR] yang-to-sources: Unable to generate sources with org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl generator
java.lang.NullPointerException: Target type not yet generated: InputEffectiveStatementImpl{path=AbsoluteSchemaPath{path=[(a)a-cont, (a)a-act, (a)input]}}
    at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.augmentationToGenTypes (AbstractTypeGenerator.java:796)
    at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.allAugmentsToGenTypes (AbstractTypeGenerator.java:375)
    at java.util.ArrayList.forEach (ArrayList.java:1257)
    at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.<init> (AbstractTypeGenerator.java:203)
    at org.opendaylight.mdsal.binding.generator.impl.CodegenTypeGenerator.<init> (CodegenTypeGenerator.java:32)
    at org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl.generateTypes (BindingGeneratorImpl.java:64)
    at org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl.generateSources (CodeGeneratorImpl.java:70)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.generateSourcesWithOneGenerator (YangToSourcesProcessor.java:383)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.generateSources (YangToSourcesProcessor.java:332)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute (YangToSourcesProcessor.java:159)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute (YangToSourcesMojo.java:127)

 



 Comments   
Comment by Miroslav Kovac [ 27/Feb/20 ]

if the action in the grouping of the module a would be enhanced with container inside of the input and the augmation of the module b would have path to that container this would generate everything just fine

Comment by Robert Varga [ 27/Feb/20 ]

The problem is that findChildNodeByPath() is not equipped to handle action's mode of generation – the action itself is generated at its instantiation, but its input/output structures are generated at its original definition. Hence in this example (a = foo, b=bar for clarity) it looks for:

AbsoluteSchemaPath{path=[(foo)foo-cont, (foo)foo-act, (foo)input]}

whereas the correct type should be

AbsoluteSchemaPath{path=[(foo)foo-grp, (foo)foo-act, (foo)input]}

as present in the lookup. There is no way findChildNodeByPath() can now this trick, nor does augmentationToGenTypes() know enough (all it has is SchemaNodeIdentifier).

Perhaps actionsToGenType() should register the paths it is reusing as proxies? Note these proxies need to be ignored for purposes of 'what Types do we need to generate'.

Comment by Robert Varga [ 28/Feb/20 ]

While the case provided here is fixed, there is another problem, which is the following:

module baz {
  yang-version 1.1;
  namespace "baz";
  prefix baz;

  import foo {
    prefix foo;
  }

  container baz-cont {
    uses foo:foo-grp {
      augment foo-act/input {
        leaf baz-aug-leaf {
          type string;
        }
      }
    }
  }
}
Generated at Wed Feb 07 20:09:59 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.