Skip to content

Failure to parse hexadecimal and octal numbers in YAML #525

@junyoneyama

Description

@junyoneyama

Discussion?

No

Describe the bug

Dasel 3.3.1 fails to parse hexadecimal and octal numbers in YAML.

To Reproduce

❯ dasel version
v3.3.1
❯ dasel -i yaml -o json <<<'0x10'
dasel: error: error reading input: yaml: unmarshal errors:
                line 1: strconv.Atoi: parsing "0x10": invalid syntax
❯ dasel -i yaml -o json <<<'0o10'
dasel: error: error reading input: yaml: unmarshal errors:
                line 1: strconv.Atoi: parsing "0o10": invalid syntax

Note: Though binary numbers and 0-prefixed octal numbers were abolished in YAML 1.2, those interpretation had changed in dasel v3.

❯ dasel -i yaml -o json <<<'0b10'
dasel: error: error reading input: yaml: unmarshal errors:
                line 1: strconv.Atoi: parsing "0b10": invalid syntax
❯ dasel -i yaml -o json <<<'010'
10

Expected behavior

dasel parses 0x.. and 0o.. into numbers.

❯ dasel -i yaml -o json <<<'0x10'
16
❯ dasel -i yaml -o json <<<'0o10'
8

dasel 2.8.1 worked as expected.

❯ ASDF_DASEL_VERSION=2.8.1 dasel -r yaml -w json <<<'0x10'
16
❯ ASDF_DASEL_VERSION=2.8.1 dasel -r yaml -w json <<<'0o10'
8
❯ ASDF_DASEL_VERSION=2.8.1 dasel -r yaml -w json <<<'0b10'
2
❯ ASDF_DASEL_VERSION=2.8.1 dasel -r yaml -w json <<<'010'
8

Desktop (please complete the following information):

  • OS: macOS Tahoe 26.3
  • Version: 3.3.1

Additional context

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