Skip to content

fix(scripts): route 'Plan template not found' per --json in setup-plan.ps1 (parity with bash)#3241

Merged
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/setup-plan-template-not-found-parity
Jun 29, 2026
Merged

fix(scripts): route 'Plan template not found' per --json in setup-plan.ps1 (parity with bash)#3241
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/setup-plan-template-not-found-parity

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

Description

When no plan template resolves, the bash setup-plan.sh emits:

if $JSON_MODE; then echo "Warning: Plan template not found" >&2
else echo "Warning: Plan template not found"; fi

The PowerShell twin used Write-Warning "Plan template not found", which renders WARNING: Plan template not found on PowerShell's warning stream — diverging from bash in both wording (WARNING: vs Warning:) and routing (warning stream vs stderr/stdout per mode). It is also inconsistent with the sibling "Copied plan template" message in the same block, which #3198 just aligned to the per---json pattern.

Fix

Route the message the same way as bash and the sibling: [Console]::Error.WriteLine under -Json (so stdout stays pure JSON), Write-Output otherwise, with bash's exact wording. Completes the parity started in #3198.

Testing

  • uvx ruff check clean; tests/test_ps1_encoding.py green (.ps1 stays ASCII).
  • New test_ps_setup_plan_template_not_found_warning_matches_bash: with no resolvable template, -Json mode now emits Warning: Plan template not found on stderr with stdout still parseable JSON. Fails before (it was WARNING: on the warning stream), passes after.
  • Verified with Windows PowerShell 5.1; existing setup-plan tests still pass.

AI Disclosure

  • I did use AI assistance (describe below)

Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI spotted the leftover Write-Warning divergence beside the #3198-aligned sibling; I confirmed the bash wording/stream and verified fail-before/pass-after under Windows PowerShell 5.1, and reviewed the diff before submitting.

…n.ps1 (parity with bash)

The 'template not found' fallback used Write-Warning, which emits 'WARNING: Plan template not found' on the warning stream -- diverging from the bash twin (echo 'Warning: Plan template not found' to stderr in --json, stdout in text mode) in both wording and routing, and inconsistent with the sibling 'Copied plan template' message (github#3198) in the same block. Route it the same way so the two scripts share one status-output contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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

This PR aligns the PowerShell setup-plan.ps1 “plan template not found” message with the bash twin by matching both the exact wording (Warning: …) and the stream routing behavior in -Json mode (stderr so stdout remains valid JSON).

Changes:

  • Replace Write-Warning "Plan template not found" with conditional output: stderr in -Json mode, stdout otherwise, using bash-matching text.
  • Add a regression test ensuring -Json mode keeps stdout parseable JSON while emitting the warning on stderr when no template resolves.
Show a summary per file
File Description
scripts/powershell/setup-plan.ps1 Routes “Warning: Plan template not found” to stderr only in -Json mode (stdout otherwise), matching bash wording and JSON-stream expectations.
tests/test_setup_plan_no_overwrite.py Adds a PowerShell regression test asserting stderr warning + stdout JSON when the template cannot be resolved.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

@mnriem mnriem merged commit 804e732 into github:main Jun 29, 2026
12 checks passed
@mnriem

mnriem commented Jun 29, 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.

3 participants