Skip to content

Consolidate binary-mode env-strip lists into a shared data file - #14925

Merged
cderv merged 1 commit into
mainfrom
task/consolidate-env-strip-vars
Sep 23, 2026
Merged

cderv merged 1 commit into
mainfrom
task/consolidate-env-strip-vars

Conversation

@cderv

@cderv cderv commented Sep 22, 2026

Copy link
Copy Markdown
Member

tests/quarto-cmd.ts's kStripEnvVars, run-tests.ps1's $probeStrip, and run-tests.sh's inline env -u chain hand-maintained three copies of the same environment-variable list, introduced together in #14706. They had already drifted at that point: the shell/PowerShell probes were missing 7 names present in the TypeScript list, including QUARTO_VERSION_REQUIREMENT.

Fix

All three now read a single tracked file, tests/binary-mode-strip-env.txt, at runtime, with identical parse semantics: trim (including a trailing CR), skip blank lines and # comments, validate each name against ^[A-Za-z_][A-Za-z0-9_]*$, and fail closed on a missing, unreadable, empty, or malformed file.

buildBinaryEnv() is split into a pure sanitizeBinaryEnv(ambient, overlay) so the strip/overlay contract (overlay applied after removal, may reintroduce a stripped name) is unit-testable without mutating Deno.env directly.

Verification

A CI guard that set QUARTO_VERSION_REQUIREMENT on the binary-mode workflow steps was considered and dropped. Both launcher scripts special-case --version to print a static version and exit without invoking Deno at all, so no environment variable can affect that probe's outcome regardless of whether the strip list is correct — the guard would have been dead code.

Test plan

  • New unit tests (tests/unit/binary-mode-strip-env.test.ts) cover the parsed list shape and the sanitizeBinaryEnv() strip/overlay/non-mutation contract
  • Verified each of the three readers fails closed when the list file is renamed away, and rejects a malformed entry such as FOO=bar
  • Ran the real preflight probe in both run-tests.sh and run-tests.ps1 against an installed quarto outside the checkout, confirming the parsed 16-name list strips correctly end to end

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR

@posit-snyk-bot

posit-snyk-bot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv

cderv commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts, merged main into this branch, and pushed the follow-up fixes in 55aeaf7e.

@cderv
cderv force-pushed the task/consolidate-env-strip-vars branch from 55aeaf7 to 3867150 Compare September 23, 2026 12:53
tests/quarto-cmd.ts's kStripEnvVars, run-tests.ps1's $probeStrip, and
run-tests.sh's inline env -u chain hand-maintained three copies of the same
list, and had already drifted (the shell probes were missing 7 names,
including QUARTO_VERSION_REQUIREMENT) at the moment they were introduced in
#14706. All three now read tests/binary-mode-strip-env.txt at runtime, with
identical parse semantics (trim including CR, skip blanks/#comments,
validate ^[A-Za-z_][A-Za-z0-9_]*$, fail closed on missing/empty/malformed).

buildBinaryEnv() is split into a pure sanitizeBinaryEnv(ambient, overlay)
so the strip/overlay contract is unit-testable without touching
Deno.env directly (test-anti-patterns.md forbids Deno.env.set()).

The originally planned CI regression guard (setting
QUARTO_VERSION_REQUIREMENT on the binary-mode workflow steps) was dropped:
verified empirically that both launcher scripts (run-tests.sh's `quarto`,
run-tests.ps1's `quarto.cmd`) special-case --version to print a static
version and exit without ever invoking Deno, so no environment variable
can affect that probe's outcome. The guard would have been dead code.
@cderv
cderv force-pushed the task/consolidate-env-strip-vars branch from 3867150 to b4c5704 Compare September 23, 2026 13:18
@cderv
cderv merged commit 90ea7ae into main Sep 23, 2026
53 of 54 checks passed
@cderv
cderv deleted the task/consolidate-env-strip-vars branch September 23, 2026 16:09
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