Skip to content

ResolveLeafrefTarget Not returning correct vlaue in case of List inside choice where list's key is a leafref #981

Open

Description

@Sneh-Prabha

I used ygot/generator/generator.go to generate the gostruct file using yang files as input.
I have a scenario where following heirarchy of elements causing the error.

/container/choice/case/container/list/leaf (leaf is of leafref type)

I have debugged and found that in api ResolveLeafrefTarget in ygot/yangschema/yangschema.go file
fixedPath, err := fixSchemaTreePath(path, contextEntry) --> here value is fixedPath doesnt has choice and case name which is ended in error of "could not resolve leafref path"

Let me know if this kind of scenario is supported in ygot.

Activity

  1. robshakir commented on Jul 26, 2024

    @robshakir
    Member

    Please can you provide a module that creates this issue. It's likely that we have a test coverage issue, since choice and case are not widely used in models that we see heavy use of.

  2. Sneh-Prabha commented on Aug 29, 2024

    @Sneh-Prabha
    Author

    Hi ,
    Sorry for the delay in response. Following module creates this issue :

    module test {
    yang-version 1.1;
    namespace "http://www.test.com/yang/ocnos/test";
    prefix "test";
    grouping a-state {
    container b-state {
    choice c-detail {
    case tagged {
    container details {
    list detail {
    key "id port-name tag-value";
    max-elements 1;
    leaf id {
    type leafref {
    path "../config/id";
    }
    }
    leaf port-name {
    type leafref {
    path "../config/port-name";
    }
    }
    leaf tag-value {
    type leafref {
    path "../config/tag-value";
    }
    }
    container config {
    uses config-common;
    uses config-tagged;
    }
    }
    }
    }
    }
    }
    }
    container abc {
    uses a-state;
    }
    grouping config-common {
    leaf id {
    type uint32 {
    range "0..65535" {
    }
    }
    }
    leaf port-name {
    type string {
    length "3..64";
    pattern "[^?' =,>|]+";
    }
    }
    }
    grouping config-tagged {
    leaf tag-value {
    type tag_value_t;
    }
    leaf tag-format {
    type tag_format_t;
    mandatory true;
    }
    }
    typedef tag_value_t {
    type string {
    length 1..4;
    pattern "([2-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-3][0-9][0-9][0-9])|(40[0-9][0-4])";
    }
    }
    typedef tag_format_t {
    type string {
    length 4..6;
    pattern "(0x8100)|(0x88a8)";
    }
    }
    }

    I ran following command :
    go run /root/go/pkg/mod/github.com/openconfig/ygot@v0.25.4/generator/generator.go -generate_fakeroot -output_file test.go -package_name goabc -exclude_modules ietf-interfaces -path https://github.com/openconfig/public --generate_simple_unions abc.yang

    Got following error :
    F0829 13:50:40.354242 21675 generator.go:382] ERROR Generating GoStruct Code: could not resolve leafref path: [abc b-state details detail config id]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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