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

Bug in anchor handling? #166

Closed
jcfj opened this issue Dec 17, 2020 · 2 comments
Closed

Bug in anchor handling? #166

jcfj opened this issue Dec 17, 2020 · 2 comments

Comments

@jcfj
Copy link

jcfj commented Dec 17, 2020

I encountered the following yaml document in the wild:

nodeGroups:
  - <<: &node-shared
      privateNetworking: true
      ssh:
        allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key
    name: ng-1
    instanceType: t3.medium
    desiredCapacity: 1
  - name: ng-2
    <<: *node-shared
    instanceType: t3.small
    desiredCapacity: 2
    maxSize: 3
    minSize: 1

Parsing and printing it with:

    println!("{:#?}", yaml_rust::YamlLoader::load_from_str(example).unwrap()[0]);

on yaml-rust v0.4.4 yields something odd:

Hash(
    {
        String(
            "nodeGroups",
        ): Array(
            [
                Hash(
                    {
                        String(
                            "<<",
                        ): Hash(
                            {
                                String(
                                    "privateNetworking",
                                ): Boolean(
                                    true,
                                ),
                                String(
…

Notice the String("<<")?

Is that a bug in the parser, or is that document simply not valid YAML 1.2?

@cilindrox
Copy link

you cannot alias/anchor an array on yaml - see yaml/yaml#35

@jcfj
Copy link
Author

jcfj commented Jul 2, 2021

Oh, woops, this issue was still open...

cf. dtolnay/serde-yaml#163 (comment), Merge keys are not part of Yaml 1.2, and simply not supported. So no, this isn't a bug.

@cilindrox If you check the debug output above, the "<<" are inside of a Hash. It has nothing to do with arrays.

@jcfj jcfj closed this as completed Jul 2, 2021
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

No branches or pull requests

2 participants