Repository navigation
fix(lint): escape workflow command properties in --gha output - #379
Open
tomaionescu wants to merge 1 commit into
Open
tomaionescu wants to merge 1 commit into
tomaionescu wants to merge 1 commit into
Conversation
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).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
erc7730 lint --ghaprints GitHub workflow commands (::error file=...,title=...::message).GithubAnnotationsAdderwrotefileandtitleinto the command as is and only escaped\nin the message.The runner splits properties on
,(ActionCommand.cs), so a title with a comma is cut there. Titles frompydantic_error_to_outputareInvalid 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: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/coredoes (escapeData/escapePropertyinpackages/core/src/command.ts). They escape%,\rand\nin the message, plus:and,in property values.%is escaped first: the runner decodes%25last, so it gets the original text back.lineis an int and is unchanged. Bothlintpaths (v1 and v2) use this adder.With the change the same error is printed as:
and the full title is shown.
Tests
tests/common/test_output.py. It covers a comma in the file name and title,%and\r\nin the message, and a:in the message that must stay as is. It fails onmainand passes here.pdm run test: 523 passed, 4282 skipped.prek run --all-fileswith the hook environments on Python 3.12, as in CI: no hook failed and no file was changed.erc7730 lint --ghaontests/resources/serve/usdt-descriptor.jsonwith an invalidformat, then parsed the output the way the runner does. Before the fix the title stopped attransfer(address _to; after it, the title is complete.AI-assisted.