github / github/vscode-github-actions
`if` conditional marked as error if the YAML string is double quoted
- Linguagem predominante
- TypeScript
- Estrelas
- 660
- Forks
- 213
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
**Describe the bug**
I have an `if` in my workflow that looks like this:
```yaml
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
```yaml
---
# 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
```yaml
---
if: !!str !startsWith(matrix.os, 'ubuntu-')
```
**To Reproduce**
Use a double quoted condition.
**Expected behavior**
No error.
**Screenshots**

**Extension Version**
`v0.25.3`
Guia de contribuição
Direção de pesquisa
Reproduce the problem in the GitHub Actions extension using the double-quoted condition shown in the issue, then compare it with the listed working and failing YAML forms. Trace the expression validation path responsible for the unexpected quote error; done means the quoted condition is accepted without an error while existing valid forms continue to work.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- github-actions, typescript, vscode
- Domínio
- devtools
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 45/100