Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should choice and case identifiers be included in leafref path? #733

Open
ythadhani opened this issue Oct 4, 2022 · 1 comment
Open

Comments

@ythadhani
Copy link

ythadhani commented Oct 4, 2022

I have the following YANG:

choice a-or-b {
case a {
list interface {
key "name";
leaf name {
type string;
}
}
}
}

leaf mgmt-interface {
type leafref {
path "../interface/name";
}
}

I want the leaf "mgmt-interface" to reference the leaf "name". If I use the path "../interface/name", I run into the failure:
ERROR Generating GoStruct Code: unable to resolve leafref field: could not resolve leafref path...

This occurs because the schemaTree at: https://github.com/openconfig/ygot/blob/master/ygen/schematree.go#L83 contains the choice and case identifiers: "a-or-b", "a" as branches. It works if I change my leafref path to: "../a-or-b/a/interface/name".

Should the schemaTree contain choice/case statements? If yes, should I update my leafref path to: "../a-or-b/a/interface/name" or should ygot be ignoring case/choice branches while walking the schema tree looking for leafs?

@wenovus
Copy link
Collaborator

wenovus commented Oct 4, 2022

Yes this does appear to be an oversight. When adding nodes to the schematree we should skip through choice/case elements instead of adding them.

I think fixing involves changing schemaTreeChildrenAdd() such that instead of calling util.Children, util.FindFirstNonChoiceOrCase is called instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants