-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
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 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
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,
- Added a new device with single address and checked if UI shows the same address.
- Did 1. with 3 addresses and with double quotes.
- looking for more testcases...
(ref: "syncthing cli config devices add" reflect error when using --addresses flag syncthing/syncthing#8503)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels