Skip to content

[Bug]: Bash scripts return non-ASCII feature directories from feature.json in the Windows code page instead of UTF-8 #5593

Backlog

Description

Bug Description

When jq is not on PATH, read_feature_json_feature_directory in scripts/bash/common.sh parses .specify/feature.json with python3 and returns the value with print(). On Windows, Python encodes a piped stdout in the ANSI code page (cp1252 on Western systems, GBK on Simplified Chinese ones), not UTF-8. A non-ASCII feature directory therefore reaches bash in that code page: specs/001-café comes back as specs/001-caf\xe9, and FEATURE_DIR, IMPL_PLAN and the other paths the bash scripts derive from it are no longer valid UTF-8.

#4780 made this reader decode feature.json as UTF-8 but left its output in the code page. The GitHub extension's copy of the reader (extensions/github/scripts/bash/resolve-tasks.sh, which says it mirrors core) prints the same way and still decodes the file with the locale encoding.

It needs a working python3 on PATH (for example from the Microsoft Store Python package; the App Execution Alias stub that Windows ships without Python fails and falls through to the grep/sed fallback, #3304) and no jq.

Steps to Reproduce

From a Spec Kit checkout in Git Bash on Windows, with a working python3 and no jq:

repo=$(mktemp -d); mkdir -p "$repo/.specify" "$repo/specs/001-café"
printf '{"feature_directory":"specs/001-café"}\n' > "$repo/.specify/feature.json"
stub=$(mktemp -d); printf '#!/bin/sh\nexit 1\n' > "$stub/jq"; chmod +x "$stub/jq"   # force the python3 parser
PATH="$stub:$PATH" bash -c 'source scripts/bash/common.sh; read_feature_json_feature_directory "$1"' _ "$repo" | od -c

On Linux or macOS, prefix the last command with PYTHONIOENCODING=cp1252, the encoding a Windows pipe uses by default.

Expected Behavior

The UTF-8 bytes of specs/001-café (... c a f 303 251), as with jq or with the grep/sed fallback.

Actual Behavior

0000000   s   p   e   c   s   /   0   0   1   -   c   a   f 351

"é" arrives as the single cp1252 byte 0xE9. In a sample project (specify init --integration claude --script sh, feature 001-café created by create-new-feature.sh), setup-plan.sh --json then prints JSON that is not valid UTF-8:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9: invalid continuation byte
FEATURE_DIR":"/c/Users/.../specs/001-caf\xe9"

With a GBK stdout (PYTHONIOENCODING=gbk, as on Simplified Chinese Windows), specs/001-功能 comes back as GBK bytes, and the GitHub extension's resolve-tasks.sh --json fails with ERROR: Feature directory not found.

Specify CLI Version

1.4.6.dev0 (main at f201054)

AI Agent

Not applicable (scripts run directly)

Operating System

Windows 11 (10.0.26300), Git for Windows (GNU bash 5.3.15)

Python Version

Python 3.14.6

Error Logs

See Actual Behavior.

Additional Context

AI Disclosure

Found, reproduced and written up by Claude Code (model: Claude Opus 5.5), running autonomously with default settings, on behalf of joshinitin2016883-sketch, who approved filing it. The agent ran the reproductions above on the reporter's Windows 11 machine; the reporter did not review this report line by line.

Activity

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