Repository navigation
Description
Copilot's review of #265 pointed out that setup-environment's "Environment file not found" error prints the environment input inside a ::error:: line without escaping it (discussion_r4491500321). That is true, and #265 did not introduce it. Before #265, ${{ inputs.environment }} put the same text into the same echo. The same pattern is in 30 annotation lines across six actions and one script.
The runner reads an annotation's message as a workflow command's data. A %, CR or LF in it has to be written %25, %0D or %0A:
- An unescaped line break ends the annotation early. What follows is a new log line, which the runner reads as a workflow command if it starts with
::. - An unescaped
%0Ain a value is shown as a line break.
The severity is low. Every value below is the calling workflow's own input, or derived from one, and a workflow can print any command it likes itself. It matters when an input is built from text the workflow does not control, such as a branch name or a pull request title. It is still the one place where the actions print caller text without the care the rest of the code takes, and three places already do it right.
Where values are already escaped
build-lectures/action.yml:125-128, theerror-outputscheck.preview-netlify/action.ymlandpreview-cloudflare/action.yml: theeschelper, forplaceholderandnetlify-site-name.scripts/preview-decide.sh:63,fail()throughesc.scripts/detect-changed-lectures.sh:48-56,warn().restore-jupyter-cache/action.yml, theCheck inputsstep (Move the remaining${{ }}expressions inrun:scripts intoenv:(PLAN item 18) #228, and restore-jupyter-cache: a mis-cased save-cache value silently stops the cache updating, and unknown input values are accepted #236 after it).
Where they are not (on ea01c01)
| File | Lines | Value printed | From input | Line break already refused? |
|---|---|---|---|---|
build-jupyter-cache/action.yml |
189 | $token |
builders |
yes: tokens are split on whitespace |
build-jupyter-cache/action.yml |
197, 204 | $RECEIVED |
builders |
yes: CR and LF are turned into spaces |
build-lectures/action.yml |
149 | $PDF_SOURCE |
output-dir |
no |
build-lectures/action.yml |
170 | $NB_SOURCE |
output-dir |
no |
build-lectures/action.yml |
210 | $SOURCE_DIR |
source-dir |
no |
build-lectures/action.yml |
226, 228 | $TOP, the work tree's root as git reports it |
source-dir |
no |
deploy-cloudflare/action.yml |
132 | $REQUIRE_ACCESS |
require-access |
no |
deploy-cloudflare/action.yml |
135 | $VISIBILITY |
visibility |
no |
deploy-cloudflare/action.yml |
151 | $TEAM_DOMAIN |
team-domain |
no |
deploy-cloudflare/action.yml |
172 | $WORKER_NAME |
worker-name |
no |
deploy-cloudflare/action.yml |
177 | $ACCOUNT_SUBDOMAIN |
account-subdomain |
no |
deploy-cloudflare/action.yml |
182, 184 | $ALIAS |
alias |
no |
deploy-cloudflare/action.yml |
189, 191 | $BUILD_DIR |
build-dir |
yes, at line 188 |
publish-gh-pages/action.yml |
97 | $MODE |
mode |
no |
publish-gh-pages/action.yml |
119 | $ASSET_NAME |
asset-name |
no |
restore-jupyter-cache/action.yml |
307 | $CACHE_PATH |
path |
yes, since #228 |
setup-environment/action.yml |
116, 129, 147 | $ENV_UPDATE; at 147 also $FILE_NAME, the name: read from that file |
environment-update |
no |
setup-environment/action.yml |
150, 218 | $ENV_NAME |
environment-name |
no |
setup-environment/action.yml |
181 | $ENV_FILE |
environment |
no |
setup-environment/action.yml |
278, 290 | $LATEX_REQUIREMENTS_FILE |
latex-requirements-file |
no |
scripts/package-release-assets.sh |
46, 51 | $BUILD_DIR |
publish-gh-pages' build-dir |
no |
Values the actions build themselves are left out: exit codes, step outcomes, modes after validation, URLs made from validated names, and input names. So are the scripts that only this repository's own workflows run (check-base-pins.sh, delete-pr-images.sh, detect-changed-images.sh, create-ci-failure-issue.sh).
The annotations are not the whole of it. A plain echo of an input with a line break in it can start a workflow command too: publish-gh-pages' "Preparing build directory: …", for example, or build-lectures' build command line. Escaping is right for an annotation, but a log line should show the value as it is.
Proposal
- Refuse a line break in every single-line input, in each action's first step. A path, a name, a mode or a key never needs one.
restore-jupyter-cache(Move the remaining${{ }}expressions inrun:scripts intoenv:(PLAN item 18) #228) anddeploy-cloudflare'sbuild-diralready do this. This closes the plain-echocase too, and most of the table's "no" rows become "yes". - Escape every input printed in an annotation, with one helper. Either one sourced file,
scripts/workflow-command.shwithesc(), found from$GITHUB_ACTION_PATH/../scripts/aspublish-gh-pagesfindspackage-release-assets.shand the preview actions findpreview-comment.cjs, or the same four-line function inline in each step that needs it. The file is one copy to keep right, but adds a file each action must find at run time. The inline function needs no lookup, but is a copy per step. Both escape%first, then CR, then LF, as the existing copies do. Note: do each substitution as a plain assignment. Inside double quotes,"${s//$'\n'/'%0A'}"keeps the single quotes literally in some bash versions, andlocal s=${…}can word-split in old ones. - Keep each message readable. Brackets or quotes around the value, as most messages already have.
Harness
- A job like
unit-line-breakfor each action whose first step gains the line-break check: a single-line control that passes, then each input with a line break failing the action before anything runs. - A test of the helper itself, if it is a file:
%, CR, LF,%0Ain the input, and a value with spaces and a glob, each coming out as one escaped line. - Optionally, a check in
scripts/lint-shell.py(ci(harness): shellcheck the actions' run: scripts and scripts/*.sh in the gate (#100) #266) that flags an annotationechoprinting a$VARthat does not go through the helper.
Not in scope
- Annotations whose values the actions build themselves, listed above.
- The repository's own workflows and their scripts.
Related: #228, #236, #265, #266.
Claude Code (on behalf of mmcky), drafted by the mini:actions-issue228 session and filed by the organiser
Activity
fix: refuse a line break in each single-value input, and escape every…
ci(harness): preview-comment knows the check step's new env, and test…
docs(preview): name each input's line-break error in full (#267)
fix: refuse a line break in each single-value input, and escape every…
release: v0.16.0 (#278)
deploy-release: the review's changes (#355)
feat: deploy-release, a reusable workflow that deploys a release to G…