Skip to content

Int instead of string added to a document #327

@wino45

Description

@wino45

Describe the bug
When I try to put "string" value while the string happens is a valid int for Go, the int is put in the document.
This is not expected, because, one cannot add a string (singe character) like this: '0'.

To Reproduce

echo 't:' | dasel put -r yaml -t string -v "0x12_11" -s 't' | dasel -r yaml 't.type()'
number

Since the string is provided, I have expected string on output, not int.
Same for bool:

echo 't:' | dasel put -r yaml -t string -v "true" -s 't' | dasel -r yaml 't.type()'
bool

As a bonus two panics:
echo '' | dasel put -r yaml -t string -v "0x12_11" -s 't'
panic: reflect: call of reflect.Value.Set on zero Value

echo 't:' | dasel put -r yaml -t string -v "0x12_11" -s ''
panic: reflect: reflect.Value.Set using unaddressable value

Expected behavior
Add string to a document as requested by user.
Add value to an empty document on first panic.
Do not panic on second panic.

Desktop (please complete the following information):

  • Windows 11
  • dasel version v2.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions