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

fix(data): show error when --data mixes data types #372

Merged
merged 2 commits into from
May 18, 2024

Conversation

reubenmiller
Copy link
Owner

Invalid shorthand json provided by the user on --data no longer panics. Instead an more helpful error message is given to the user.

Previously the following would cause a panic because the one property is being used to assing both a number and an object.

Example

Below shows the new behaviour (e.g. error message instead of a panci):

c8y devices create -n --data one=1 --data one.two=null --dry
2024-05-18T23:17:04.910+0200    ERROR   commandError: json error: data parameter does not contain valid json or shorthand json. Invalid shorthand JSON: mixed types detected. trying to assign an object to a float64. path=one

@reubenmiller reubenmiller linked an issue May 18, 2024 that may be closed by this pull request
@reubenmiller reubenmiller merged commit b5fa65c into v2 May 18, 2024
4 checks passed
@reubenmiller reubenmiller deleted the fix-mixed-shorthand-json branch May 18, 2024 21:49
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 this pull request may close these issues.

body: panic when mixing data types when building a body
1 participant