Skip to content

fix(openapi): make client generators portable on Windows - #9759

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-openapi-generators
Jul 18, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-openapi-generators

Conversation

@tianmind-studio

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

Copy link
Copy Markdown
Contributor

Summary

  • read and write all Dart, TypeScript, and Swift OpenAPI generator files explicitly as UTF-8
  • emit slash-stable source labels in generated TypeScript and Swift headers on every OS
  • handle TypeScript and Swift output paths outside the repository without relative_to() failures
  • add subprocess regression coverage with Python UTF-8 mode disabled, plus Windows path-label tests

Root cause

The client generators used Path.read_text() and Path.write_text() without an encoding. On Windows, Python therefore inherited the active ANSI code page. The UTF-8 app-client contract failed to decode under GBK before generation started.

After forcing UTF-8 manually, TypeScript --check still reported all four committed outputs as stale because the generated header embedded a Windows backslash path while the committed Linux-generated header used forward slashes. The Swift generator had the same path-label contract, and both generators assumed every explicit output lived under the repository root.

This was visible in the contributor path because scripts/pre-push invokes all three generator checks directly; it does not inherit the UTF-8 export used by backend/test.sh.

Scope and safety

  • generator file I/O, generated-file labels, diagnostics, and regression tests only
  • no OpenAPI schema, generated client API, backend route, application runtime, or deployment behavior changes
  • generated outputs remain byte-stable on Linux and use explicit LF newlines when written on Windows

Product invariants affected

None.

Verification

  • real Windows checks with PYTHONUTF8 unset:
    • python backend/scripts/generate_dart_models.py --all --check
    • python backend/scripts/generate_ts_openapi_types.py --check
    • python backend/scripts/generate_swift_openapi_types.py --check
  • official backend runner for the three generator test files: 43 passed
  • forced non-UTF-8 locale and Windows path regression subset: 5 passed
  • Black 24.4.2 and Ruff 0.4.4: passed
  • diff hygiene, lifecycle headers, versioned filenames, import purity, test isolation, workflow contracts, async blocker, route policy, and conversation lifecycle guards: passed

The full 601-file backend run had one unrelated Windows CPU-time guard at the exact 0.12s threshold; all four assertions in that file passed, and the same file passed its isolated official-runner retry in 0.10s. The aggregate preflight also encounters the existing Windows Firestore path-normalization false positive fixed by #9683; checks after that gate were run directly and passed.

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for tightening this up — this looks like a useful portability fix for the OpenAPI client generators.

I reviewed the diff and ran the generator checks locally in a scrubbed environment with LANG=C, LC_ALL=C, PYTHONCOERCECLOCALE=0, and PYTHONUTF8=0:

  • python backend/scripts/generate_ts_openapi_types.py --check
  • python backend/scripts/generate_swift_openapi_types.py --check
  • python backend/scripts/generate_dart_models.py --all --check

Those passed, and the Swift/TypeScript generator unit tests also passed locally (15 passed). The changes are appropriately scoped to explicit UTF-8 file I/O, LF writes, stable slash-separated path labels, and regression coverage. I did not see a security or supply-chain concern in the implementation.

I'm not formally approving from automation because this touches generator/pre-push-sensitive tooling and the review policy requires human maintainer review for that surface, but this is a positive signal from my side.


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

@Git-on-my-level Git-on-my-level added the needs-maintainer-review Needs a human maintainer to sign off before merge label Jul 15, 2026

@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.

Reviewed — looks good; not auto-merging (over scope/size or non-bug area), landing left to maintainer.

@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.

backend bug fix (conf 4/5): make OpenAPI client generators portable on Windows (explicit UTF-8 encoding + slash-stable paths); tests, CI green

@kodjima33
kodjima33 merged commit 0cd4461 into BasedHardware:main Jul 18, 2026
25 of 28 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants