vscode-github-actions icon indicating copy to clipboard operation
vscode-github-actions copied to clipboard

`if` conditional marked as error if the YAML string is double quoted

Open briantist opened this issue 1 year ago • 3 comments

Describe the bug I have an if in my workflow that looks like this:

if: "!startsWith(matrix.os, 'ubuntu-')"

The conditional is quoted because ! has meaning in YAML to change the type, so we can't start a string with that character without a way to tell the YAML parser it's a string. This works fine in the workflow.

However, it's marked as an error by this extension:

Unexpected symbol: '"'. Located at position 1 within expression: "!startsWith(matrix.os, 'ubuntu-')"

Workarounds that work

  • Single quotes (NOTE double quotes can't be used inside expression apparently)
  • YAML multi-line strings
  • Unnecessary templating
---
# Note double single quotes internally
if: '!startsWith(matrix.os, ''ubuntu-'')'

---
if: >-
  !startsWith(matrix.os, 'ubuntu-')

---
if: ${{ !startsWith(matrix.os, 'ubuntu-') }}

Workarounds that don't work

  • explicit str typing
---
if: !!str !startsWith(matrix.os, 'ubuntu-')

To Reproduce Use a double quoted condition.

Expected behavior No error.

Screenshots image

Extension Version v0.25.3

briantist avatar Mar 29 '23 12:03 briantist