Skip to content

DO-2055: improve extra env variable support - #204

Merged
tmthrgd-aligent merged 12 commits into
mainfrom
fix/DO-2055_handle_trailing_env_newlines
Nov 17, 2026
Merged

tmthrgd-aligent merged 12 commits into
mainfrom
fix/DO-2055_handle_trailing_env_newlines

Conversation

@tmthrgd-aligent

@tmthrgd-aligent tmthrgd-aligent commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Description of the proposed changes

Context

aio-app-deployment.yml and aws-cdk.yml failed when their extra env var inputs ended with a newline, and extra secrets weren't masked. node-pr.yml had its own copy of this logic, with its own problems: it kept CRs and misread some base64 lines as new variables.

Changes

Move extra env var handling into composite actions shared by all three workflows.

  • Add export-env-vars. It writes its input to $GITHUB_ENV and lets the runner parse it, so KEY=VALUE lines and KEY<<DELIMITER blocks work and blank lines are ignored. It removes CRs with a warning, and with mask: true it masks values before they are written.
  • Use it in aio-app-deployment.yml and aws-cdk.yml, with mask: true for the secrets.
  • Add convert-legacy-env-vars to convert node-pr's ENV_VARS format to $GITHUB_ENV format. Use it in node-pr.yml in place of the old parser. The legacy multiline format still works but shows a deprecation warning.
  • Update the docs for all three workflows.

Test

  • Run aio-app-deployment.yml or aws-cdk.yml with an extra secret that ends with a newline. The deploy should succeed, with the secret values masked in the log.
  • Run node-pr.yml with a multiline ENV_VARS in the legacy format, saved with CRLF line endings. The values should be exported and masked, with warnings about the legacy format and the CRs.

Screenshots (if applicable)

Other solutions considered (if any)

Notes to PR author

  • ⚠️ Please make sure the changes adhere to the guidelines mentioned in our contribution guide.

Notes to reviewers

  • ℹ️ When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

Time Tracking

  • DO-2055: code review, select project Dev OpsTeam

🤖 Generated with Claude Code

This will replace the env var handling in aio-app-deployment.yml and
aws-cdk.yml, both of which fail when their input has a trailing newline.

It additionally handles empty lines and comments starting with #. The
previous loop handled the empty lines but not comments.
This replaces the manual loop in aio-app-deployment.yml and aws-cdk.yml
with the export-env-vars composite action.
@tmthrgd-aligent
tmthrgd-aligent force-pushed the fix/DO-2055_handle_trailing_env_newlines branch from c87c44e to 328cd16 Compare November 13, 2026 06:28
tmthrgd-aligent and others added 8 commits November 16, 2026 15:01
Values from AIO_DEPLOY_EXTRA_SECRETS and EXTRA_SECRETS were written to
$GITHUB_ENV without being masked, so they could appear in later log
output.

Add a mask input to export-env-vars. When 'true', each value is masked
before it is written to $GITHUB_ENV, so it is already masked when later
steps list the environment in their log headers. Multiline
(KEY<<DELIMITER) values are masked line by line.

aio-app-deployment.yml and aws-cdk.yml now call the action twice: once
for the variables, and once for the secrets with mask: true. This
replaces the value2 input.

The input is now passed to $GITHUB_ENV as is, apart from removing
carriage returns (with a warning), so the runner handles the parsing,
including multiline blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
node-pr had its own parser for ENV_VARS, duplicated in the build and
test jobs. Replace it with export-env-vars, so all three workflows
export extra environment variables the same way.

ENV_VARS uses a legacy format that $GITHUB_ENV doesn't accept: any line
that doesn't start a new KEY= continues the previous value. The new
convert-legacy-env-vars action converts it to $GITHUB_ENV format by
writing each variable as a KEY<<DELIMITER block with a random delimiter.
KEY<<DELIMITER blocks already in the input are passed through, so
ENV_VARS now also accepts anything $GITHUB_ENV does.

The legacy multiline format still works but is deprecated and shows a
warning. It can misread a base64 line ending in = padding as a new
variable, cutting the value short; KEY<<DELIMITER blocks avoid this.

Both actions are called with mask: true. The converted text is passed
to export-env-vars through `with:`, where it no longer matches the
original secret, so convert-legacy-env-vars masks every line of it.

Other changes from the old parser:
- Carriage returns are removed, with a warning, by export-env-vars.
- Blank lines inside a multiline value are kept.
- HAVE_SECRETS_ENV_VARS is removed. Both steps handle an empty ENV_VARS,
  so they no longer need a condition.

Document the ENV_VARS format and update the SSH key example to use a
KEY<<DELIMITER block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… docs

ENV_VARS accepts the $GITHUB_ENV format plus the legacy continuation-line
format, not exactly the $GITHUB_ENV format. In the legacy format, a line
after a variable that isn't KEY=value continues that variable instead
of failing.

has-env-vars is already ignored by node-pr. Mark it as deprecated in the
inputs table and remove it from the examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runner decodes %0A and %0D in add-mask values, then masks the whole
value and each of its lines, ignoring empty lines and trimming
whitespace. So the converted output can be masked with one command
instead of one per line.

Skip masking when the output is empty or whitespace, as the runner warns
about empty add-mask values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI's yamllint step failed with line-length errors on the warning lines
in convert-legacy-env-vars (251 characters) and export-env-vars (232),
over the 120 character limit.

Split each message across several lines. echo and awk's print both join
their arguments with a space, so the warning text and its single-line
output are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace printf '%s\n' "$INPUT_VALUE" | cmd with cmd <<< "$INPUT_VALUE"
where the action input is fed to tr or awk. A here-string adds the same
single trailing newline as printf '%s\n', so the input and output are
unchanged, without the extra pipeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
convert-legacy-env-vars:
- Print the legacy format warning straight to stderr instead of routing
  it through fd 3. $(...) only captures awk's stdout, and the runner
  processes workflow commands on stderr as well as stdout.

export-env-vars:
- Remove CRs inside the mask awk instead of piping its input through
  tr.

Remove the comments explaining that echo and print join their
arguments with a space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…v-vars

zizmor flags the $GITHUB_ENV write (code scanning alert 500), as input
written there can set variables that run code in later steps, such as
BASH_ENV, LD_PRELOAD or NODE_OPTIONS. Exporting caller-supplied
variables is what the action is for, so suppress the finding and
document the risk: in the action description, and above the write.

The finding appeared after switching the write to a here-string. zizmor
did not detect the same write at the end of a pipeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmthrgd-aligent tmthrgd-aligent changed the title DO-2055: handle trailing env newlines DO-2055: improve extra env variable support Nov 16, 2026

@AdamJHall AdamJHall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one minor change to invert the mask variable just to be extra safe.

Defaulting mask to 'false' meant forgetting it silently left secrets
unmasked. Make mask required on export-env-vars and
convert-legacy-env-vars, so every caller has to choose.

The runner doesn't enforce required inputs (a missing input is an empty
string), so both actions now fail unless mask is 'true' or 'false'.
This also catches typos such as 'ture'.

The variables calls in aio-app-deployment.yml and aws-cdk.yml now pass
mask: false. The secrets calls and node-pr already pass mask: true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AdamJHall
AdamJHall previously approved these changes Nov 16, 2026
@tmthrgd-aligent
tmthrgd-aligent merged commit 3ccb0c6 into main Nov 17, 2026
3 checks passed
@tmthrgd-aligent
tmthrgd-aligent deleted the fix/DO-2055_handle_trailing_env_newlines branch November 17, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants