You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding a new item to a slice of structs via CLI flags, if a struct field was a slice of strings (e.g., []string), the parsing logic in makeSliceItemBuilders would not correctly identify it as a string slice. This was because the switch statement was checking simplifyKind(fieldValue.Kind()) which would be reflect.Slice or reflect.Array, not the kind of the elements within the slice. (fixes syncthing/syncthing#9058)
Solution
As this repo is closed for contribution from other, I am unable to raise a PR but here are my changes tejas-rkd@7a6d10b
Modified the makeSliceItemBuilders function in recli.go. The inner switch statement that handles reflect.Array and reflect.Slice now correctly uses elemKind := simplifyKind(fieldValue.Type().Elem().Kind()) to determine the type of the elements within the slice. This ensures that string slices are correctly identified and processed using ctx.StringSlice(flagName).
Testing
In Syncthing,
Added a new device with single address and checked if UI shows the same address.
This is an issue which impacts downstream syncthing cli parsing for string array parsing.
Fixes syncthing/syncthing#9058
Problem
When adding a new item to a slice of structs via CLI flags, if a struct field was a slice of strings (e.g.,
[]string), the parsing logic inmakeSliceItemBuilderswould not correctly identify it as a string slice. This was because theswitchstatement was checkingsimplifyKind(fieldValue.Kind())which would bereflect.Sliceorreflect.Array, not the kind of the elements within the slice. (fixes syncthing/syncthing#9058)Solution
As this repo is closed for contribution from other, I am unable to raise a PR but here are my changes tejas-rkd@7a6d10b
makeSliceItemBuildersfunction in recli.go. The innerswitchstatement that handlesreflect.Arrayandreflect.Slicenow correctly useselemKind := simplifyKind(fieldValue.Type().Elem().Kind())to determine the type of the elements within the slice. This ensures that string slices are correctly identified and processed usingctx.StringSlice(flagName).Testing
In Syncthing,
(ref: "syncthing cli config devices add" reflect error when using --addresses flag syncthing/syncthing#8503)