Skip to content

Fix packaged backend crashing on Windows at startup - #4

Merged
carthworks merged 1 commit into
mainfrom
claude/pensive-shannon-afywuj
Oct 5, 2026
Merged

carthworks merged 1 commit into
mainfrom
claude/pensive-shannon-afywuj

Conversation

@carthworks

Copy link
Copy Markdown
Owner

The first run of the Windows backend package CI job (on #3) caught a ship-blocking bug:

File "server.py", line 17, in <module>
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f680'
[PYI-1532:ERROR] Failed to execute script 'server' due to unhandled exception!

When stdout is a pipe, which is how Electron launches the backend, Windows Python encodes output as cp1252. That code page can't encode the emoji in the startup banner or the OCR log messages, so server.exe died immediately. Every Windows install would have shown "The processing engine did not start".

Changes

  • backend/server.py: reconfigure stdout/stderr to UTF-8 (errors='replace') before importing the app.
  • backend/tests/test_entrypoint.py: new test that starts the real server.py with PYTHONIOENCODING=cp1252 and piped output, then requires /api/health. Verified it fails without the fix and passes with it.
  • scripts/smoke-test-backend.ps1: stop waiting as soon as the backend process exits, and print its stdout/stderr. Previously it polled for 90 seconds after a crash.

Testing

  • Reproduced the crash locally under cp1252, then confirmed the fixed server starts and answers /api/health.
  • ruff check clean. The new test passes, and fails on the old code.
  • The real confirmation is this PR's Windows backend package job, which builds server.exe with PyInstaller and smoke-tests it with the bundled Tesseract.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jze3nDgZGqUXGceiu5RCAf


Generated by Claude Code

The first Windows CI run showed server.exe dying immediately with
UnicodeEncodeError: when stdout is a pipe (as when Electron launches the
backend), Windows Python uses cp1252, which cannot encode the emoji in the
startup banner and OCR log messages. Every Windows install would have shown
"processing engine did not start".

- server.py: reconfigure stdout/stderr to UTF-8 (errors=replace) before
  importing the app
- tests/test_entrypoint.py: start server.py with PYTHONIOENCODING=cp1252 and
  piped output and require /api/health (fails without the fix)
- smoke-test-backend.ps1: stop waiting as soon as the backend exits and print
  its stdout/stderr, instead of polling for 90 seconds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jze3nDgZGqUXGceiu5RCAf
@ecc-tools

ecc-tools Bot commented Oct 5, 2026

Copy link
Copy Markdown

ECC Tools / Security Evidence

Commit: 6be73afea21d2ecb7aecfc5d65d02f5f8484ccbc

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 3 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 5, 2026

Copy link
Copy Markdown

ECC Tools / PR Risk Taxonomy

Commit: 6be73afea21d2ecb7aecfc5d65d02f5f8484ccbc

PR taxonomy review recommended (neutral)

Detected 1 PR taxonomy bucket(s): CI/CD Recommendation.

Scanned 3 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • Regression coverage may lag behind the diff
  • 0 CI or workflow path(s) changed

Paths:

  • backend/server.py
  • backend/tests/test_entrypoint.py
  • scripts/smoke-test-backend.ps1

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 5, 2026

Copy link
Copy Markdown

ECC Tools / Reference Set Readiness

Commit: 6be73afea21d2ecb7aecfc5d65d02f5f8484ccbc

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 3 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 5, 2026

Copy link
Copy Markdown

ECC Tools / Hosted Promotion Readiness

Commit: 6be73afea21d2ecb7aecfc5d65d02f5f8484ccbc

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 3 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@carthworks
carthworks merged commit b6f4489 into main Oct 5, 2026
4 checks passed
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.

2 participants