Skip to content

[Bug] Unmarshal does not support the full range of valid characters as specified in the spec for anchors and aliases #44

@TyIsI

Description

@TyIsI

As discussed with @ingydotnet; opening here after discussion on mikefarah/yq#2406 as yq depends on this library and the bug has been confirmed to be related to this library.

Describe the bug

In the yq application, it is possible render/resolve anchors/aliases through the explode operator.

Unmarshalling fails due to parsing errors in this library.

Other used library has been confirmed not being the cause.

Reproduction

Reproduced in https://github.com/TyIsI/fafo-go-yaml/blob/main/yaml-go-yaml/main.go

More info from original issue

Input Yaml

Message.yml:

references:
    - &network.core.v1.Ping ./network/core/v1/Ping.yml
    - &network.core.v1.Pong ./network/core/v1/Pong.yml
    - &network.enums.v1.MessageType ./network/enums/v1/MessageType.yml
---
Message:
    - - type: *network.enums.v1.MessageType
        payload: *network.core.v1.Ping
      - type: *network.enums.v1.MessageType
        payload: *network.core.v1.Pong

Command

yq -P eval-all "explode(.) | select(document_index == 1)" Message.yml

Actual behavior

Error: bad file 'Message.yml': yaml: line 2: did not find expected alphabetic or numeric character

Expected behavior

Message:
  - - type: ./network/enums/v1/MessageType.yml
      payload: ./network/core/v1/Ping.yml
    - type: ./network/enums/v1/MessageType.yml
      payload: ./network/core/v1/Pong.yml

Additional context

If I remove the dots and use dashes (-) or slashes (/) instead, it also doesn't work. Single string works fine.

Easy link to the spec:
https://yaml.org/spec/1.2.2/#rule-ns-anchor-name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions