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

False Positive On Aliases In Mapping Nodes #133

Open
Kurt-von-Laven opened this issue Apr 21, 2022 · 5 comments
Open

False Positive On Aliases In Mapping Nodes #133

Kurt-von-Laven opened this issue Apr 21, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@Kurt-von-Laven
Copy link

Kurt-von-Laven commented Apr 21, 2022

Actionlint complains "with" section is alias node but mapping node is expected [syntax-check] on valid YAML syntax when anchors and aliases are used with mapping nodes:

- name: Run my-action.
  run: my-organization/my-action
  with: &my-action-inputs
    a: b
    c: d
    e: f
- name: Run my-action again.
  run: my-organization/my-action
  with: *my-action-inputs

I am uncertain how one would suppress the error.

@rhysd
Copy link
Owner

rhysd commented Apr 24, 2022

Yeah, aliases are actually not considered because I've never used them in my workflows and anyone didn't report that previously. But I agree this should not cause false positive at least.

@rhysd rhysd added the bug Something isn't working label Apr 24, 2022
@rhysd
Copy link
Owner

rhysd commented Apr 25, 2022

I created a minimal workflow to reproduce this:

name: Test
on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Run my-action.
        uses: my-organization/my-action@main
        with: &my-action-inputs
          a: b
          c: d
          e: f
      - name: Run my-action again.
        uses: my-organization/my-action@main
        with: *my-action-inputs

@prein
Copy link

prein commented Nov 21, 2022

Consider also yaml anchors (if you didn't already)
Example:

name:  Test
on: push
jobs:
  test1:
    runs-on: ubuntu-latest
    steps:
    - &run_action
      name: Run my-action
      uses: my-organization/my-action@main
  test2:
    runs-on: ubuntu-latest
    steps:
    - name: Restore built artifacts from cache
      <<: *run_action

@dannystaple
Copy link

I see a false positive on most aliases. This manifests as:

.github/workflows/terraform_apply_promote.yml:27:26: expected scalar node for string value but found alias node with "" tag [syntax-check]
   |
27 |       terraform_version: *tf_ver

As it stands, if being used in superlinter, we cannot even use the command line to override this, since the exclusions aren't available in actionlint.yml. At this point we are left with:

  • repeat the code n times (so much for DRY)
  • Use actionlinter outside of superlinter so it's behaviour can be customised
  • Don't use actionlinter

All of which are sub-optimal. it suggests that the way this is linting is some AST that is running before aliases are resolved.

@Kurt-von-Laven
Copy link
Author

This doesn't solve your problem, but to toot my own horn, MegaLinter runs significantly faster than Super-Linter, and has many more linters. It also has actionlint.

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

4 participants