Closed bortok closed 7 months ago
Hi @bortok basically we made a change in openapiart that all the fields in proto will be made optional, https://github.com/open-traffic-generator/snappi/pull/212 This helps in validating required fields more efficiently as earlier required fields for primitive types were difficult to check for example lets a and required field of integer as we know by default the integer in gosnappi is assigned a value of zero now in order for us to check if user has set a value zero to this field it becomes difficult for us to know whether the required integer field was set by user or not
That's why accessing router id without setting it results in an error as accessing nil pointer, User get to know this cause SDK throws an error if it is not set.
I guess a better way of checking would be this
for _, d := range config.Devices().Items() {
if d.HasBgp() {}
}
we were also thinking to introduce has method for every field i.e to have HasRouterId() for which we have raised a PR (currently in review with @ashutshkumr) but we have not decided on it yet https://github.com/open-traffic-generator/openapiart/pull/454
for _, d := range config.Devices().Items() {
if d.Bgp().HasRouterId() != nil {} // as router id is now a string pointer and not a string
}
Thanks, confirming the fix works
After upgrading to
gosnappi:0.13.0
the following code ofotgen
(run.go) causes panic:encountered with the following OTG configuration otg.panic.yml.txt – it doesn't have BGP configuration, and the code above is trying to detect if BGP is configured
See the CI test run for details https://github.com/open-traffic-generator/otgen/actions/runs/6601539315/job/17933084738