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

body: panic when mixing data types when building a body #284

Closed
reubenmiller opened this issue Jul 4, 2023 · 0 comments · Fixed by #372
Closed

body: panic when mixing data types when building a body #284

reubenmiller opened this issue Jul 4, 2023 · 0 comments · Fixed by #372

Comments

@reubenmiller
Copy link
Owner

The following example triggers a panic as it mixes data types (e.g. number with an object).

c8y devices create --data one=1 --data one.two=null --dry

Output

panic: interface conversion: interface {} is float64, not map[string]interface {}
goroutine 1 [running]:
github.com/reubenmiller/go-c8y-cli/v2/pkg/jsonUtilities.setValue(0x14000501860, {0x140005b209a?, 0x103372a50?}, {0x0?, 0x0})
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/jsonUtilities/shorthand.go:216 +0x1e8
github.com/reubenmiller/go-c8y-cli/v2/pkg/jsonUtilities.parseShorthandJSONStructure({0x140005b209a, 0xc}, 0x140005b209a?)
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/jsonUtilities/shorthand.go:190 +0x16c
github.com/reubenmiller/go-c8y-cli/v2/pkg/jsonUtilities.ParseJSON({0x140005b209a, 0xc}, 0x14000501860)
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/jsonUtilities/shorthand.go:57 +0x8c
github.com/reubenmiller/go-c8y-cli/v2/pkg/flags.WithDataValueAdvanced.func1(0x1400038c7e0?, 0x1031d4eb7?)
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/flags/getters.go:896 +0x2b8
github.com/reubenmiller/go-c8y-cli/v2/pkg/flags.WithBody(0x0?, 0x1400038c7e0, 0x14000501140, {0x140000b5798, 0x8, 0x102b38934?})
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/flags/getters.go:148 +0xb0
github.com/reubenmiller/go-c8y-cli/v2/pkg/cmd/devices/create.(*CreateCmd).RunE(0x1400071e680, 0x0?, {0x0?, 0x0?, 0x0?})
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/cmd/devices/create/create.auto.go:137 +0x768
github.com/reubenmiller/go-c8y-cli/v2/pkg/cmd/subcommand.NewSubCommand.func1(0x14000730f00?, {0x140003755f0, 0x0, 0x9})
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/cmd/subcommand/subcommand.go:55 +0x6c
github.com/spf13/cobra.(*Command).execute(0x14000730f00, {0x14000375560, 0x9, 0x9})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:916 +0x5f4
github.com/spf13/cobra.(*Command).ExecuteC(0x140003a4000)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:1040 +0x354
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:968
github.com/reubenmiller/go-c8y-cli/v2/pkg/cmd.MainRun()
	/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/cmd/cmd.go:101 +0x188
main.main()
	/home/runner/work/go-c8y-cli/go-c8y-cli/cmd/c8y/main.go:8 +0x20
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

Successfully merging a pull request may close this issue.

1 participant