Skip to content

Error when opening yaml with number as key #7222

Closed

Description

@oberien

Describe the bug

Trying to open yaml using a number as a key results in an error:

〉"200:" | from yaml
Error: nu::shell::unsupported_input (link)

  × Unsupported input
   ╭─[entry #59:1:1]
 1 │ "200:" | from yaml
   ·          ────┬────
   ·              ╰── Unexpected YAML:
Key: Number(200)
Value: Null
   ╰────

This seems to be a bug in nu and not serde_yaml. The latter parses the input just fine (playground:

fn main() {
    let foo: serde_yaml::Value = serde_yaml::from_str("200:").unwrap();
    println!("{foo:?}");
}

> Mapping(Mapping { map: {Number(PosInt(200)): Null} })

How to reproduce

"200:" | from yaml

Expected behavior

I expected nu to support opening yaml files with numbers as keys.

Screenshots

No response

Configuration

key value
version 0.70.0
branch makepkg
commit_hash 9ef65dc
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.64.0 (Arch Linux rust 1:1.64.0-1)
cargo_version cargo 1.64.0
pkg_version 0.70.0
build_time 2022-10-19 07:28:38 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. added
    category:bug
    A:file-format
    on Nov 24, 2022
  2. sholderbach commented on Nov 24, 2022

    @sholderbach
    Member

    Our internal Value::Record format only supports strings as keys like json. But deserializing that to the string representation should absolutely be doable.

  3. added this to the v0.74 milestone on Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:file-formatcategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions