Closed raghavendramayagundi closed 1 year ago
This could be related to the issue I wrote a testcase for in #86... its also related to typedef-leaflist combination.
@raghavendramayagundi could you test if the error goes away if you "inline" the typedef ?
@HRogge by "inline" if you mean to use "type string; default 7;" directly instead of "typedef", then yes it works. Locally I tried the below fix in core_gen.go by adding "else if":
func (m *LeafList) setDefaultValue(d interface{}) {
if s, valid := d.([]string); valid {
m.defaultVals = s
} else if s, valid := d.(string); valid {
m.defaultVals = []string{s}
} else {
panic("expected []string or string")
}
}
I have a similar "fix" for a related problem somewhere else, so my guess is that the real problem is somewhere in the yang file-parser, some bad interaction between "leaf-list" (and maybe list?) and "typedef"... but I have yet to find the underlying issue.
Could you test if #93 solves your issue?
The fix did not help, got the below stack:
panic: expected []string
goroutine 1 [running]:
github.com/freeconf/yang/meta.(*LeafList).setDefaultValue(0xc0004be09e?, {0x389d40?, 0xc0004903b0?})
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/core_gen.go:1675 +0x85
github.com/freeconf/yang/meta.(*compiler).compileType(0xc000028390?, 0xc00054e9a0, {0x47e080?, 0xc0001e2240}, 0x0)
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:262 +0x175
github.com/freeconf/yang/meta.(*compiler).compile(0xc0004419d0, {0x3db500?, 0xc0001e2240?})
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:81 +0x16a
github.com/freeconf/yang/meta.(*compiler).compile(0xc0004419d0, {0x3db1e0?, 0xc0001e2000?})
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:138 +0x713
github.com/freeconf/yang/meta.(*compiler).compile(0xc0004419d0, {0x3dbbc0?, 0xc00004b1e0?})
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:138 +0x713
github.com/freeconf/yang/meta.(*compiler).module(0x331d8b?, 0xc00004b1e0)
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:54 +0x206
github.com/freeconf/yang/meta.Compile(0xc00004b1e0)
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/meta/compile.go:22 +0xb8
github.com/freeconf/yang/parser.LoadModuleWithOptions(0xc0004921e0, {0xc00009e0a0, 0xc}, {{0x0?, 0x0?}, {0x0?, 0xc000441c50?}})
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/parser/loader.go:72 +0x1fd
github.com/freeconf/yang/parser.LoadModule(...)
C:/MyData/Projects/ESO/YANGtoJSON/Code/YangTest/freeconf/parser/loader.go:16
e2eso-json-schema-generator/generator/yangparser.(*YangParser).ParseAndGenerateJsonSchema(0xc000441cb0)
C:/MyData/Projects/ESO/YANGtoJSON/Code/e2eso-json-schema-generator/generator/yangparser/parser.go:34 +0x5f
e2eso-json-schema-generator/generator/yangparser.ConvertYangFilesToJsonSchema({0x47bd98, 0xc00063f2c0}, {0xc00000e17a?, 0x477c50?}, {0xc00009e0a0, 0xc}, {0xc000441e08, 0x2}, 0xa8?)
C:/MyData/Projects/ESO/YANGtoJSON/Code/e2eso-json-schema-generator/generator/yangparser/parser.go:283 +0xde
main.main()
C:/MyData/Projects/ESO/YANGtoJSON/Code/e2eso-json-schema-generator/main.go:90 +0x686
okay, so we are looking at different problems...
should be fixed now
If leaf-list uses type from a typedef which contains a default value, we get panic error while loading yang module:
YANG file is attached (as a txt file). type_leafref.txt