Skip to content

fix(i18n): make make gen-i18n fail loudly instead of reporting success - #305

Merged
antosubash merged 1 commit into
mainfrom
fix/gen-i18n-strict
Sep 5, 2026
Merged

fix(i18n): make make gen-i18n fail loudly instead of reporting success#305
antosubash merged 1 commit into
mainfrom
fix/gen-i18n-strict

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Closes #302

The problem

emit_frontend_types swallows every write failure by design — a live boot prefers stale types to a broken start. scripts/gen_i18n.py inherited that behaviour and then printed "i18n key files regenerated" unconditionally, so the command whose only job is writing those two files reported success identically whether it wrote them or wrote nothing at all. The script configured no logging either, so the logger.info("Wrote %s (%d keys)", …) lines that would have distinguished the two cases were below the root threshold and never appeared.

The next symptom was a tsc error about a key that does exist in the catalog — several steps removed from the cause.

The fix

  • emit_frontend_types / emit_frontend_types_for_modules take strict: bool = False. Under strict they re-raise instead of logging, and a missing packages/i18n/src is an error rather than a silent skip. The boot path is unchanged: default strict=False keeps stale-types-over-broken-boot, and a missing package directory stays the normal shape of a wheel-installed app with no i18n workspace.
  • scripts/gen_i18n.py passes strict=True, configures logging for the i18n_manifest logger only (root stays at WARNING, so discovery's per-module chatter doesn't bury the answer), and closes with "i18n key files up to date".
  • Refreshed two comments naming UserManager.generate_verification_token, collapsed into mint_invite_token and resolving to nothing in this tree (tests/e2e/conftest.py, modules/users/tests/test_user_manager.py).

Verification

Before / after on an unwritable keys.generated.ts:

old new
output i18n key files regenerated PermissionError: [Errno 13] …
exit 0 1

Normal run, with a file to write:

$ make gen-i18n
Wrote keys.generated.ts
i18n key files up to date
  • uv run pytest framework/hosting/tests/test_i18n_manifest.py framework/hosting/tests/test_strict_discovery_wiring.py modules/users/tests/test_user_manager.py — 36 passed (5 new, covering strict/non-strict × missing-package/write-failure)
  • ruff format --check, ruff check, ty check framework/hosting scripts, check_file_size.py — all pass

`emit_frontend_types` swallows every write failure by design — a live boot
prefers stale types to a broken start. `scripts/gen_i18n.py` inherited that
and then printed "i18n key files regenerated" unconditionally, so the command
whose only job is writing those two files reported success identically whether
it wrote them or wrote nothing. With no logging configured, the per-file INFO
lines that would have distinguished the two never appeared either. The next
symptom was a `tsc` error about a key the catalog does contain.

Add a `strict` flag to `emit_frontend_types` / `emit_frontend_types_for_modules`
that re-raises rather than logging, and pass it from the script. Under strict a
missing `packages/i18n/src` is an error too, where on the boot path it stays the
normal shape of a wheel-installed app that ships no i18n workspace.

The script now configures logging for that one logger — the root stays at
WARNING so discovery's per-module chatter doesn't bury the two lines that answer
the question the command was run to ask.

Also refresh two comments naming `UserManager.generate_verification_token`,
which was collapsed into `mint_invite_token` and resolves to nothing today.

Closes #302
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-04T20:59:17.099215Z caa1b34 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: caa1b34
Status: ✅  Deploy successful!
Preview URL: https://14b06d9c.simple-module-python.pages.dev
Branch Preview URL: https://fix-gen-i18n-strict.simple-module-python.pages.dev

View logs

@antosubash
antosubash merged commit c7e4b7a into main Sep 5, 2026
13 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.

make gen-i18n prints success and exits 0 even when it wrote nothing

1 participant