Skip to content

fix(scripts): reconfigure setup_plan.py streams as UTF-8 - #5569

Merged
mnriem merged 1 commit into
github:mainfrom
adityajai119:fix/5567-setup-plan-utf8-streams
Nov 25, 2026
Merged

mnriem merged 1 commit into
github:mainfrom
adityajai119:fix/5567-setup-plan-utf8-streams

Conversation

@adityajai119

Copy link
Copy Markdown
Contributor

Fixes #5567

What

scripts/python/setup_plan.py now reconfigures stdout and stderr to UTF-8 before main() runs, mirroring the existing helper in scripts/python/setup_tasks.py.

Why

When either stream is redirected on Windows with a legacy code page (cp1252 in the reproduction), print() of a feature path containing non-ASCII characters raised UnicodeEncodeError and aborted plan setup before plan.md was created. The other Python workflow helpers already reconfigure both streams; setup_plan.py was the outlier.

Tests

  • New tests/test_setup_plan_utf8_output.py runs the script as a real subprocess with PYTHONIOENCODING=cp1252 and ascii, covering a non-ASCII feature path (positive) plus invalid SPECIFY_INIT_DIR and broken template-composition layers (negative).
  • Red on main: 8 failed. Green after fix: 8 passed.
  • Adjacent: 92 passed, 44 skipped across setup-plan, setup-tasks, and resolve-template parity/text suites.
  • uvx ruff@0.15.0 check src tests: all checks passed.
  • Both repository guard scripts: pass. specify --help: exit 0. git diff --check: clean.

AI disclosure

This PR, its paired issue, its commit, and its tests were authored by an AI agent (OpenCode, model: Gemini 4 Neon, autonomous) acting for adityajai119. The contributor did not line-by-line review the change; automation produced the verification evidence above.

Redirected runs on a legacy Windows code page raised UnicodeEncodeError when setup_plan.py printed a non-ASCII feature path. The sibling Python helpers already reconfigure both streams; mirror that helper here.

Fixes github#5567

Assisted-by: OpenCode (model: Gemini 4 Neon, autonomous)
@adityajai119
adityajai119 requested a review from mnriem as a code owner November 25, 2026 16:19
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 16:19

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.

🟢 Approval recommended

No active review issues are present, and the change includes targeted regression coverage for legacy-encoding output and related error paths.

No open issues 🎉

What changed in this PR

This pull request fixes setup_plan.py failures when redirected stdout or stderr uses a legacy encoding on Windows, aligning it with the existing UTF-8 stream handling in setup_tasks.py and adding subprocess regression coverage.

Changes:

  • Reconfigure stdout and stderr to UTF-8 with safe error handling before executing main().
  • Add coverage for non-ASCII paths, text and JSON output, invalid initialization directories, and template-resolution errors under cp1252 and ascii environments.
File Description
tests/​test_setup_plan_utf8_output.py Adds subprocess regression tests for non-ASCII paths, UTF-8-safe text and JSON output, and error handling.
scripts/​python/​setup_plan.py Adds UTF-8 stream configuration at the script entry point before plan setup execution.

Review effort: Lite (adaptive)

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.

🟢 Approval recommended

No active review issues were identified for the UTF-8 output change, though reported test results were not independently rerun.

No open issues 🎉

Review effort: Balanced

@mnriem
mnriem merged commit bf67456 into github:main Nov 25, 2026
14 checks passed
@mnriem

mnriem commented Nov 25, 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.

fix(scripts): setup_plan.py crashes on non-ASCII feature paths under a legacy stdout code page

3 participants