Skip to content

fix(scripts): send check-prerequisites.ps1 errors to stderr#3123

Merged
mnriem merged 2 commits into
github:mainfrom
Quratulain-bilal:fix/check-prereqs-errors-to-stderr
Jun 23, 2026
Merged

fix(scripts): send check-prerequisites.ps1 errors to stderr#3123
mnriem merged 2 commits into
github:mainfrom
Quratulain-bilal:fix/check-prereqs-errors-to-stderr

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

closes #3122

check-prerequisites.ps1 wrote its validation errors and run-hints with Write-Output, so they went to stdout. the script is usually run with -Json and its stdout is parsed as json by the agent, so when validation fails (e.g. missing plan.md) the parser gets an error string instead of json and breaks.

the bash counterpart already sends these to stderr (>&2), and the sibling powershell scripts (setup-tasks.ps1, common.ps1's Get-FeaturePathsEnv) already use [Console]::Error.WriteLine. this switches the six error/hint lines in check-prerequisites.ps1 to [Console]::Error.WriteLine so stdout stays clean and the two shells behave the same.

no behaviour change on the success path - only the failure paths, which still exit 1.

note: i used an ai assistant to help investigate and prepare this change. disclosing per CONTRIBUTING.md.

The validation errors and run-hints in check-prerequisites.ps1 were
written with Write-Output, so they went to stdout. This script is
usually run with -Json and its stdout parsed by the agent, so an error
(e.g. missing plan.md) leaves the parser with an error string instead
of JSON. The bash counterpart already writes these to stderr (>&2), as
do the sibling PowerShell scripts (setup-tasks.ps1, common.ps1's
Get-FeaturePathsEnv). Switch the six error/hint lines to
[Console]::Error.WriteLine so stdout stays clean and the two shells
match.

Copilot AI 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.

Pull request overview

Aligns the PowerShell prerequisite checker with the bash version by ensuring validation failures don’t pollute -Json stdout output, preventing downstream JSON parsing errors in agent/automation consumers.

Changes:

  • Switched prerequisite validation error/hint messaging from Write-Output (stdout) to [Console]::Error.WriteLine(...) (stderr).
  • Preserved the success-path behavior and JSON payload output (only failure-path messaging stream changed).
Show a summary per file
File Description
scripts/powershell/check-prerequisites.ps1 Routes prerequisite failure messages to stderr so -Json stdout remains valid JSON for consumers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@mnriem

mnriem commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Can you also address the requested test changes as per #3122 bug assessment?

Per the github#3122 bug assessment, tighten the failure-path tests so they
verify stdout stays clean (empty / valid JSON) and the error text only
appears on stderr, instead of checking the combined stdout+stderr
string. Covers all three PowerShell validation paths (missing feature
dir, missing plan.md, missing tasks.md with -RequireTasks) and the bash
counterpart. The two new error-routing tests fail on the pre-fix
script (errors on stdout) and pass after it.
@Quratulain-bilal

Copy link
Copy Markdown
Contributor Author

done - tightened the failure-path tests to assert stdout stays clean (empty/valid json) and the error only shows on stderr, instead of the old combined stdout+stderr check. added cases for the missing plan.md and missing tasks.md (-RequireTasks) paths too. confirmed the two error-routing tests fail on the pre-fix script and pass after the fix.

Copilot AI 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.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new

@mnriem mnriem merged commit 0ef53eb into github:main Jun 23, 2026
11 checks passed
@mnriem

mnriem commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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.

[Bug]: check-prerequisites.ps1 writes errors to stdout, corrupting --json output

3 participants