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

Reusing YAML anchor results in configuration error #55378

Closed
cowboy opened this issue Aug 28, 2021 · 6 comments
Closed

Reusing YAML anchor results in configuration error #55378

cowboy opened this issue Aug 28, 2021 · 6 comments

Comments

@cowboy
Copy link

cowboy commented Aug 28, 2021

The problem

Per the YAML 1.2 spec, "anchors need not be unique" https://yaml.org/spec/1.2/#id2765878

However, the attached section in my configuration.yaml file reuses the turn_on anchor, and results in the following error when running ha core check:

Processing... Done.

Error: Testing configuration at /config
ERROR:homeassistant.util.yaml.loader:found duplicate anchor 'turn_on'; first occurrence
  in "/config/configuration.yaml", line 50, column 18
second occurrence
  in "/config/configuration.yaml", line 57, column 18
Failed config
  General Errors: 
    - Error loading /config/configuration.yaml: found duplicate anchor 'turn_on'; first occurrence
  in "/config/configuration.yaml", line 50, column 18
second occurrence
  in "/config/configuration.yaml", line 57, column 18

Successful config (partial)

I can work around this issue by giving the anchors unique names, eg. turn_on1, turn_on2, etc, but it seems like it should just work.

What is version of Home Assistant Core has the issue?

core-2021.8.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Example YAML snippet

switch:
  - platform: template
    switches:
      one:
        value_template: "off"
        turn_on: &turn_on
          service: scene.turn_on
          target:
            entity_id: scene.one
        turn_off: *turn_on
      two:
        value_template: "off"
        turn_on: &turn_on
          service: scene.turn_on
          target:
            entity_id: scene.two
        turn_off: *turn_on

Anything in the logs that might be useful for us?

No response

Additional information

No response

@probot-home-assistant
Copy link

config documentation
config source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (config) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@balloob
Copy link
Member

balloob commented Aug 30, 2021

We use YAML 1.1

@balloob balloob closed this as completed Aug 30, 2021
@cowboy
Copy link
Author

cowboy commented Aug 30, 2021

@balloob per the YAML 1.1 spec, "anchors need not be unique" https://yaml.org/spec/1.1/#id863390. Do you need me to open another issue, or will you reopen this one?

@balloob
Copy link
Member

balloob commented Aug 30, 2021

In that case it is an upstream issue in the YAML parser pyyaml

@cowboy
Copy link
Author

cowboy commented Aug 30, 2021

In case it helps anyone else, this pyyaml PR fixes the issue: yaml/pyyaml#394. Hopefully they'll merge it.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants