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

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

Open
Sneh-Prabha opened this issue Jul 23, 2024 · 2 comments

Comments

@Sneh-Prabha
Copy link

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.

@robshakir
Copy link
Contributor

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.

@Sneh-Prabha
Copy link
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/[email protected]/generator/generator.go -generate_fakeroot -output_file test.go -package_name goabc -exclude_modules ietf-interfaces -path http://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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants