Skip to content

fix(lint): escape workflow command properties in --gha output - #379

Open
tomaionescu wants to merge 1 commit into
LedgerHQ:mainfrom
tomaionescu:fix/lint-gha-escape
Open

tomaionescu wants to merge 1 commit into
LedgerHQ:mainfrom
tomaionescu:fix/lint-gha-escape

Conversation

@tomaionescu

Copy link
Copy Markdown

The bug

erc7730 lint --gha prints GitHub workflow commands (::error file=...,title=...::message). GithubAnnotationsAdder wrote file and title into the command as is and only escaped \n in the message.

The runner splits properties on , (ActionCommand.cs), so a title with a comma is cut there. Titles from pydantic_error_to_output are Invalid value at <location>, and in a calldata descriptor the location contains the format key, which is a function signature. Every schema error under a format key with two or more parameters lost the part of the title that names the field:

::error file=calldata-badformat.json,title=Invalid value at $.display.formats.`transfer(address _to, uint256 _value)`.fields[0].field_description.format::Value "tokenAmountt" is not valid: ...

The annotation title becomes Invalid value at $.display.formats.`transfer(address _to. A % in a message was also not escaped, so the runner could decode it as an escape sequence.

The fix

Two small helpers that do what @actions/core does (escapeData / escapeProperty in packages/core/src/command.ts). They escape %, \r and \n in the message, plus : and , in property values. % is escaped first: the runner decodes %25 last, so it gets the original text back. line is an int and is unchanged. Both lint paths (v1 and v2) use this adder.

With the change the same error is printed as:

::error file=calldata-badformat.json,title=Invalid value at $.display.formats.`transfer(address _to%2C uint256 _value)`.fields[0].field_description.format::...

and the full title is shown.

Tests

  • New tests/common/test_output.py. It covers a comma in the file name and title, % and \r\n in the message, and a : in the message that must stay as is. It fails on main and passes here.
  • pdm run test: 523 passed, 4282 skipped.
  • prek run --all-files with the hook environments on Python 3.12, as in CI: no hook failed and no file was changed.
  • Ran erc7730 lint --gha on tests/resources/serve/usdt-descriptor.json with an invalid format, then parsed the output the way the runner does. Before the fix the title stopped at transfer(address _to; after it, the title is complete.

AI-assisted.

GithubAnnotationsAdder wrote the file and title properties as is and
only escaped "\n" in the message. The runner splits properties on ",",
so a title built from a format key such as
"transfer(address _to, uint256 _value)" was cut at the first comma, and
a "%" in a message could be decoded as an escape sequence.

Escape the message and the property values the way @actions/core does
(escapeData and escapeProperty).
@tomaionescu
tomaionescu requested a review from a team as a code owner November 28, 2026 11:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant