Skip to content

fix(preflight): decode Git content as UTF-8 on Windows - #10595

Merged
kodjima33 merged 3 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-deployment-git-utf8
Jul 27, 2026
Merged

kodjima33 merged 3 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-deployment-git-utf8

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Decode Git repository content explicitly as UTF-8 in three deterministic preflight guards instead of using the Windows host locale:

  • deployment secret-boundary reads from git ls-tree and git show;
  • deferred-work marker reads from git diff and git show;
  • product file line-count ratchet reads baseline paths and both sharded and legacy JSON blobs from git ls-tree and git show.

Git repository paths and blobs are UTF-8 data, but Python's text=True used the active Windows code page (GBK in the reproduced environment). A valid Unicode source comment or baseline justification could therefore crash these guards before they enforced policy.

Product invariants affected

none

How it was verified

  • Before the deployment fix on native Windows, python .github/scripts/check_deployment_secret_boundary.py --base HEAD failed with UnicodeDecodeError: 'gbk' codec can't decode byte ...; the same production command passed after the fix.
  • Before the deferred-marker fix, native Windows scripts/pr-preflight crashed while decoding a real Unicode TypeScript diff.
  • Before the line-ratchet fix, native Windows preflight crashed in baseline_at_ref() while decoding a real baseline shard; the same production command now passes without PYTHONUTF8.
  • python .github/scripts/test_check_deployment_secret_boundary.py -> 9 passed.
  • python .github/scripts/test_run_checks.py DeferredMarkerTests -> 3 passed.
  • python .github/scripts/test_check_product_file_line_count_ratchet.py -> 9 passed.
  • Native Windows scripts/pr-preflight --pr-body-file ... in an integration worktree with fix(ci): support Windows in manifest preflight #10594 applied -> all 15 selected checks passed without PYTHONUTF8.
  • Black 26.5.1 with the repository's 120-column configuration, Ruff 0.4.4, and git diff --check passed on all changed Python files.

Tests

The deployment fixture commits UTF-8 workflow content, exercising the real git show path. Mocked subprocess contracts require all seven Git content reads across the three guards to pass encoding="utf-8"; the line-ratchet contract covers both sharded and legacy baseline paths, so Linux CI also rejects a future return to locale-driven decoding.

Failure class (fixes)

Failure-Class: none

Root cause and durable guard (bug fixes)

Python inherited the Windows locale when subprocess.run(..., text=True) decoded Git output. All affected guards now declare strict UTF-8 decoding at the Git boundary, with production-path and configuration-contract regression coverage.

@tianmind-studio tianmind-studio changed the title fix(preflight): decode deployment Git output as UTF-8 fix(preflight): decode Git content as UTF-8 on Windows Jul 25, 2026
@tianmind-studio
tianmind-studio force-pushed the codex/windows-deployment-git-utf8 branch from acd2c25 to 2aa869a Compare July 25, 2026 22:41
@tianmind-studio
tianmind-studio force-pushed the codex/windows-deployment-git-utf8 branch from 2aa869a to 226adc7 Compare July 26, 2026 00:36
@Git-on-my-level Git-on-my-level added workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior needs-maintainer-review Needs a human maintainer to sign off before merge labels Jul 26, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Windows preflight fix. This looks like the right direction: the changed Git subprocess reads now decode repository content as UTF-8 explicitly, and the added tests cover the deployment boundary, deferred-work marker, and line-ratchet paths that were still relying on the host locale.

I also ran the touched tests in a stripped environment:

  • python .github/scripts/test_check_deployment_secret_boundary.py -> 9 passed
  • python .github/scripts/test_check_product_file_line_count_ratchet.py -> 9 passed
  • python .github/scripts/test_run_checks.py DeferredMarkerTests -> 3 passed

No blocking code issues found from my review. Since this touches GitHub/preflight guard scripts that enforce security/workflow policy, I am leaving this as a positive maintainer signal rather than formal approval; a human maintainer should still sign off before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI check-script portability fix (UTF-8 decode of Git content on Windows). Approve-only — .github/ tooling stays out of agent merge authority.

The product line-count ratchet read baseline paths and JSON blobs with the Windows host code page. Decode all three Git content reads explicitly as UTF-8 and lock both sharded and legacy paths with a subprocess contract test.
@undivisible
undivisible force-pushed the codex/windows-deployment-git-utf8 branch from 226adc7 to 72a25e7 Compare July 27, 2026 05:02

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: text=True decoded git output with the Windows ANSI code page; the change is encoding='utf-8' on three preflight guards plus formatter reflow — no check is weakened, new regression test asserts the encoding kwarg.

@kodjima33
kodjima33 merged commit 934e6ec into BasedHardware:main Jul 27, 2026
27 checks passed
kodjima33 pushed a commit that referenced this pull request Sep 1, 2026
* fix(preflight): decode gh metadata as UTF-8

Decode captured gh PR JSON with the producer's UTF-8 encoding instead of the Windows host code page. Add a Unicode metadata contract and register the recurring subprocess locale failure class with #10595 and #10844 as evidence.

Tests: MetadataTests passed 14/14; the real #10823 body loaded under preferred_encoding=cp936; Ruff, Black, py_compile, and diff checks passed.

Failure-Class: new

* fix(preflight): propagate UTF-8 through Windows runner

* fix(preflight): pin suggestion subprocess UTF-8

* test(preflight): pin nested subprocess UTF-8

* fix(preflight): emit direct Windows output as UTF-8

---------

Co-authored-by: 491034170 <[email protected]>
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
…#10595)

* fix(preflight): decode deployment Git output as UTF-8

* fix(preflight): decode deferred-work Git output as UTF-8

* fix(preflight): decode line-ratchet Git output as UTF-8

The product line-count ratchet read baseline paths and JSON blobs with the Windows host code page. Decode all three Git content reads explicitly as UTF-8 and lock both sharded and legacy paths with a subprocess contract test.

---------

Co-authored-by: 491034170 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants