Fix two crashes that make task_showcase unusable on Windows - #67
Fix two crashes that make task_showcase unusable on Windows#67dhruv-15-03 wants to merge 1 commit into
Conversation
The bundled task showcase server returns HTTP 500 on every route when run
on Windows. Two independent, unrelated causes:
1. strftime("%-m/%-d/%Y, %-I:%M:%S %p") raises ValueError
The "%-" no-padding flag is a glibc extension. It is not part of the C
standard and the Windows CRT rejects it outright, so /task/<id> raises
ValueError: Invalid format string before rendering anything.
Replaced with direct field formatting, which needs no platform-specific
directives. Output is byte-identical to the glibc original, verified
across midday/midnight boundaries:
2026-08-02 23:13:16 -> 8/2/2026, 11:13:16 PM
2026-01-01 00:00:00 -> 1/1/2026, 12:00:00 AM
2026-12-25 12:00:00 -> 12/25/2026, 12:00:00 PM
2026-10-09 09:05:07 -> 10/9/2026, 9:05:07 AM
2. Path.read_text() without an encoding
Three call sites read JSON with no encoding argument, so Python uses the
platform default: UTF-8 on Linux/macOS, but cp1252 on most Windows
installs. Any non-ASCII character in task.json or report.json (a rupee
sign, an em dash, a non-Latin company name) raises UnicodeDecodeError,
and a BOM produces the confusing "Expecting value: line 1 column 1".
Two other read_text() calls in the same module (build_steps, line 74 and
89) already pass encoding="utf-8". This aligns the remaining three with
that existing convention.
Reproduced on Windows 11 / Python 3.12.9 / Flask 3.1.3: both / and
/task/<id> returned 500 before, and 200 after, rendering a report with 11
sections, 117 table rows and 105 cards.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dhruv-15-03 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
@microsoft-github-policy-service agree |
|
Correction to my previous comment on this PR. I entered
I do not have, and did not intend to claim, authority to bind Microsoft |
assets/task_showcasereturns HTTP 500 on every route when run on Windows. Two independent, unrelated causes.1.
strftime("%-m/%-d/%Y, %-I:%M:%S %p")raisesValueErrorThe
%-no-padding flag is a glibc extension. It is not in the C standard, and the Windows CRT rejects it outright (its equivalent is%#m)./task/<id>therefore dies withValueError: Invalid format stringbefore rendering anything.Replaced with direct field formatting, which needs no platform-specific directives. Output is byte-identical to the glibc original - verified across the noon/midnight boundaries where a naive
hour % 12would be off by twelve:2026-08-02 23:13:168/2/2026, 11:13:16 PM2026-01-01 00:00:001/1/2026, 12:00:00 AM2026-12-25 12:00:0012/25/2026, 12:00:00 PM2026-10-09 09:05:0710/9/2026, 9:05:07 AM2.
Path.read_text()without an encodingThree call sites read JSON with no
encodingargument, so Python uses the platform default - UTF-8 on Linux/macOS, but cp1252 on most Windows installs. Any non-ASCII byte intask.jsonorreport.json(a currency symbol, an em dash, a non-Latin company name) raisesUnicodeDecodeError, and a UTF-8 BOM surfaces as the rather misleadingExpecting value: line 1 column 1.Two other
read_text()calls in the same module (build_steps, lines 74 and 89) already passencoding="utf-8". This aligns the remaining three with that existing convention rather than introducing a new one.Verification
Reproduced on Windows 11 / Python 3.12.9 / Flask 3.1.3:
/and/task/<id>both returned 500.No behaviour change on Linux or macOS - the timestamp string and the decoded JSON are identical there. Single file, +12/-4, no new dependencies and no public API change.