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

YAML Anchors Causing Build Failures #100

Open
elijahe opened this issue Jan 3, 2024 · 3 comments
Open

YAML Anchors Causing Build Failures #100

elijahe opened this issue Jan 3, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@elijahe
Copy link

elijahe commented Jan 3, 2024

Orb version:

1.0.0

What happened:

When using the path-filtering orb to merge multiple configs, some of which contain yaml anchors such as the one below,

default_vars: &default_vars
  environment:
    DEBUG: true
    NODE_ENV: production

the anchors are sometimes placed at the bottom of the merged config which causes the build to fail with an error message similar to:

Unable to parse YAML
found undefined alias default
 in 'string', line 471, column 9:
        <<: *default_vars
            ^

Note: If only a single config contains anchors then this issue appears to happen sporadically depending on the order that the filtered configs are processed in. In other words, if we have 2 configs, config_1_with_anchors.yml and config_2_without_anchors.yml, if the merging code decides to process config_1_with_anchors.yml before config_2_without_anchors.yml it works just fine. If on the other hand it decides to process config_2_without_anchors.yml first and config_1_with_anchors.yml second then it fails. The order of processing appears to be non-deterministic.

Expected behavior:

Ideally YAML anchors should always be placed at the top of the merged config so that they do not cause parsing errors.

Additional context:

Here's a sample .circleci/config.yml file which reproduces the issue above:

---
version: 2.1

setup: true

orbs:
  path-filtering: circleci/[email protected]

workflows:
  generate-config:
    jobs:
      - path-filtering/filter:
          base-revision: << pipeline.git.branch >>
          mapping: |
            editor/.* build-editor true editor/.circleci/config.yml
            fe/.* build-fe true fe/.circleci/config.yml
@elijahe elijahe added the bug Something isn't working label Jan 3, 2024
@elijahe elijahe changed the title YAML Anchors Randomly Ordered When Configs are Merged YAML Anchors Randomly Ordered When Configs are Merged Causing Build Failures Jan 3, 2024
@elijahe elijahe changed the title YAML Anchors Randomly Ordered When Configs are Merged Causing Build Failures YAML Anchors Causing Build Failures Jan 3, 2024
@patrykkarny
Copy link

Hey @elijahe, thank you for reporting the issue! I'm experiencing the same problem. Have you found any solutions to avoid this error, other than consolidating the configuration into a single one?

@elijahe
Copy link
Author

elijahe commented May 10, 2024

Hi @patrykkarny , no I haven't found a solution for this issue yet. We're just avoiding YAML Anchors for now. It would be great to be able to use them again.

@pc-bob
Copy link

pc-bob commented Jul 15, 2024

A workaround has been suggest here that worked for me: #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants