Documentation bug: expression numbers are mis-documented

Aberta Para iniciantes
#43,008 11 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Documentação
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
github-actions, javascript
Domínio
documentation

Direção de pesquisa

Comece pela seção “Literals” da página sobre a sintaxe de expressões do GitHub Actions e compare as versões Free, Pro e Teams, GHES e GHEC. Revise o código-fonte do parser referenciado em expressions/src/data/string.ts, linhas 14–16, e as regras vinculadas de Number coercion. O trabalho estará concluído quando a documentação descrever corretamente os Number literals aceitos em todas as páginas afetadas.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

builder persona content github_actions never-stale
Code of Conduct
What article on docs.github.com is affected?

The "Literals" section of the GitHub Actions expression syntax page:

https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#literals

That link is for the "Free, Pro, and Teams" page, but the GHES and GHEC pages are also affected.

What part(s) of the article would you like to see updated?

The number literal is documented as "Any number format supported by JSON." However, in reality, the GitHub Actions expression parser takes a much larger set of literals, which it coerces to numbers.

For example, neither hex nor octal literals are valid in JSON, but GitHub Actions accepts them. For example:

${{ 0xff }}
${{ 0o777 }}

More generally, GitHub Actions appears to support any number literal that the JavaScript Number(...) constructor can coerce a string from. Those coercion rules are documented here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_coercion

This can be seen in the official GitHub Actions expression parser, which appears to use the Number(...) constructor when turning a StringData lexeme into a number:

https://github.com/actions/languageservices/blob/fb5c6e4f27bb1ddf512609a6a341aadd17ce86f3/expressions/src/data/string.ts#L14-L16

Additional information

Yes, this is trivially reproducible in any GitHub Actions workflow or action definition.

See https://github.com/zizmorcore/zizmor/pull/1628 for a related downstream report.

Linguagem predominante
TypeScript
Estrelas
20.9k
Forks
68.8k
Merge médio
15h 4min
PRs com merge (30d)
103

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de github/docs

Todas as issues de github/docs

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.