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

interface conversion: interface {} is json.Number, not string in sdk/framework/field_data.go #15057

Closed
valli0x opened this issue Apr 15, 2022 · 5 comments · Fixed by #15072
Closed
Labels
bug Used to indicate a potential bug devex Developer Experience

Comments

@valli0x
Copy link
Contributor

valli0x commented Apr 15, 2022

I use framework.TypeCommaIntSlice for get emloyeeID and add it in group AD in my engine.

Send: curl -X POST -H "X-Vault-Request:..." -H "X-Vault-Token: $(vault print token)" -d '{"param": 213}' http://127.0.0.1:8200/v1/

In vault system log: interface conversion: interface {} is json.Number, not string

You use StringToSliceHookFunc() in DecodeHook();

if reflect1.Kind != reflect.String || reflect2.Kind != reflect.Slice {return data, nil}
you do it : raw := data.(string)
reflect.ValueOf(json.Number), reflect.Kind() => string, reflect.Type() => json.Number

sdk/framework/field_data.go, maybe remove function mapstructure.StringToSliceHookFunc(",") from DecodeHook

commit: Brian Kassouf, 4 years ago (March 3rd, 2018 2:01 AM) logical/framework: add a field data type for parsing integer arrays, [83a7d20]

@hsimon-hashicorp hsimon-hashicorp added devex Developer Experience bug Used to indicate a potential bug labels Apr 15, 2022
@VinnyHC
Copy link
Contributor

VinnyHC commented Apr 15, 2022

Hello, @Nikita1821 thanks for opening this issue. Could you please let us know what version of Vault (found using vault status) you're experiencing this with?

@valli0x
Copy link
Contributor Author

valli0x commented Apr 17, 2022

hi, the last version

@valli0x
Copy link
Contributor Author

valli0x commented Apr 18, 2022

ok, v1.10.0

@valli0x
Copy link
Contributor Author

valli0x commented Apr 18, 2022

you can add to any engine parameter with type framework.TypeCommaIntSlice
send just int and get this error

@ccapurso
Copy link
Contributor

As @Nikita1821 noted, this occurs due to the type string assertion performed in mapstructure.StringToSliceHookFunc when the input is of type json.Number. A similar issue used to occur with framework.TypeCommaStringSlice. The parsing for that type is handled by ParseCommaStringSlice in github.com/hashicorp/go-secure-stdlib/parseutil. The issue was fixed in #14522. If the type of the input is json.Number then we simply call String(). We can likely add the same conversion for framework.TypeCommaIntSlice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug devex Developer Experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants