Skip to content

Generator: Deviations are not considered when performing leaf ref lookup. #1025

@soltas-g

Description

@soltas-g

When not-supported deviations are used on intermediate nodes, leaf ref lookups on child nodes fail with error: ERROR Generating GoStruct Code: could not resolve leafref path: [ <path> ]

This seems to be occurring in the following code section:

	e := t.GetLeafValue(fixedPath)
	if e == nil {
		return nil, fmt.Errorf("could not resolve leafref path: %v from %v, tree: %v", fixedPath, contextEntry, t)
	}

return nil, fmt.Errorf("could not resolve leafref path: %v from %v, tree: %v", fixedPath, contextEntry, t)


Deviations should be considered when performing leaf ref lookup or returning nil should not be a failure case (potentially toggle-able by flag)


Reproduction:

instance.yang

module test-instance {

  yang-version "1";

  // namespace
  namespace "instance";

  prefix "t-inst";

  grouping instance-top {
    description
      "Top-level grouping containing a list of instances.";

    container instances {
      description
        "instances";

      list instance {
        key "name";

        description
          "instances configured on the local system";

        leaf name {
          type leafref {
            path "../config/name";
          }
          description
            "A unique name identifying the instance";
        }

        container config {
          description
            "Configuration parameters relating to an
            instance";
          uses instance-config;
        }
      }
    }
  }
  grouping instance-config {
    description
      "Configuration parameters relating to a top-level
      instance";

    leaf name {
      type string;
      description
        "name for the instance.";
    }
  }
  uses instance-top;
}

test-deviations.yang

module test-deviations {

  namespace "instance-deviations";

  prefix "test-devs";

  import test-instance { prefix t-inst; }

  organization "test";

  deviation /t-inst:instances/t-inst:instance/t-inst:config {
    deviate "not-supported"; 
  }
}

ygot generator run with

-compress_paths=false -output_dir=~ -package_name=pkg -ignore_circdeps -ignore_unsupported=true -exclude_modules=ietf-interfaces  
 -generate_fakeroot -fakeroot_name=device -generate_simple_unions -generate_append -generate_getters -generate_rename -structs_split_files_count=5 -ygot_path=<> -ytypes_path=<> -goyang_path=<>  -path=test third_party/openconfig/vendor/cisco/yang/test/instance.yang third_party/openconfig/vendor/cisco/yang/test/test-deviations.yang

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions