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

if conditional marked as error if the YAML string is double quoted #60

Open
briantist opened this issue Mar 29, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@briantist
Copy link

briantist commented Mar 29, 2023

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 briantist added the bug Something isn't working label Mar 29, 2023
@lrotschy lrotschy moved this from Backlog 🗒 to Triaged 📝 in GitHub Actions VS Code Extension Apr 11, 2023
@lrotschy lrotschy moved this from Triaged 📝 to Backlog 🗒 in GitHub Actions VS Code Extension Apr 11, 2023
@jtamsut jtamsut self-assigned this Apr 11, 2023
@lrotschy lrotschy moved this from Backlog 🗒 to In progress 🚧 in GitHub Actions VS Code Extension Apr 13, 2023
@passcod
Copy link

passcod commented Apr 18, 2023

Noting that the workarounds also cause the conditional to not syntax-highlight anymore (a more minor annoyance to be sure, though).

@passcod
Copy link

passcod commented Aug 16, 2023

Another workaround which does preserve syntax highlighting is to wrap with () instead:

-    - if: "!startsWith(github.ref, 'refs/heads/release/')"
+    - if: (!startsWith(github.ref, 'refs/heads/release/'))

raineorshine added a commit to raineorshine/npm-check-updates that referenced this issue Aug 16, 2023
passcod added a commit to beyondessential/tamanu that referenced this issue Aug 16, 2023
* TAV-756: Add cutoff commit on new release branches

* TAV-756: Add release commit just before tagging

* Try to work around github/vscode-github-actions#60 again
Cyberboss added a commit to tgstation/tgstation-server that referenced this issue Aug 18, 2023
taiki-e added a commit to taiki-e/workflows that referenced this issue Aug 29, 2023
@ssbarnea
Copy link

ssbarnea commented Jan 26, 2024

Considering the lack of comments from any maintainers I am even wondering if we should assume this extension is abandonware, last release was like 9 months ago and an error like this is nowhere to be considered as a minor.

@konradpabjan Maybe you can give this one a go, please? It is insane that this is apparently caused by not using a certified YAML parsers, as the double quotes are not expected to endup even being visible in the loaded data.

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
Status: Triaged 📝
Development

Successfully merging a pull request may close this issue.

4 participants