Skip to content

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

Done

Description

@adityajai119

Bug Description

scripts/python/setup_plan.py prints feature paths (and template-resolution errors) with plain print() on stdout/stderr. On Windows, when either stream is redirected to a pipe or a file, Python falls back to the ANSI code page (for example cp1252). A project whose path contains non-ASCII characters then makes print() raise UnicodeEncodeError, aborting plan setup before plan.md is created.

The sibling helpers already handle this: scripts/python/setup_tasks.py reconfigures both streams to UTF-8, scripts/python/create_new_feature.py reconfigures stdout/stderr, and scripts/python/resolve_template.py writes raw UTF-8 bytes. setup_plan.py was left out.

Steps to Reproduce

  1. In a Spec Kit project whose absolute path contains a non-ASCII character (for example C:\projets\café), create a feature directory and a valid .specify/templates/plan-template.md.
  2. Set SPECIFY_FEATURE_DIRECTORY to that feature directory and unset SPECIFY_INIT_DIR confusion.
  3. Run python setup_plan.py --json with PYTHONIOENCODING=cp1252 (simulating a redirected Windows console).
  4. Observe a UnicodeEncodeError traceback or a non-zero exit, and no plan.md.

Expected Behavior

The script reconfigures stdout and stderr to UTF-8, prints the paths successfully, and creates plan.md from the template.

Actual Behavior

UnicodeEncodeError: 'charmap' codec can't encode character ... from the print(f"Copied plan template to {paths.impl_plan}") or the path-summary print() lines; the command exits non-zero.

Additional Context

Fix mirrors the _configure_utf8_streams() helper in scripts/python/setup_tasks.py. Positive and negative regression tests should run the script as a real subprocess with PYTHONIOENCODING=cp1252 and a non-ASCII feature path.

AI Disclosure

Filed by an AI agent (OpenCode, model: Gemini 4 Neon, autonomous) on behalf of adityajai119. The issue text was generated by the agent; the reporter has not independently reproduced it on Windows hardware.

Activity

  1. added a commit that references this issue on Nov 25, 2026
    bf67456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions