Skip to content

fix(i18n): guard template name lookups with t.has() to prevent MISSING_MESSAGE crash - #425

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
Maqbool61:fix/missing-message-template-name
Jul 15, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
Maqbool61:fix/missing-message-template-name

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

Fixes #420

Problem

Opening a report detail page crashed with: MISSING_MESSAGE: Could not resolve reports.templates.executive_summary.name in messages for locale en.

The key exists in en.json but was unresolvable at runtime due to a stale Turbopack module cache after switching branches without restarting the dev server.

Fix

Added t.has() guards at all three template-name render sites so a missing key silently omits the label instead of throwing:

reports/[id]/page.tsx — detail page header (crash site):

{KNOWN_TEMPLATE_IDS.has(report.template) && t.has(`templates.${report.template}.name`) && (
  <>{t(`templates.${report.template}.name`)} · </>
)}

reports/page.tsx — reports list table cell:

{KNOWN_TEMPLATE_IDS.has(report.template) && t.has(`templates.${report.template}.name`) && (
  <span className="mt-0.5 block text-xs text-muted-foreground">
    {t(`templates.${report.template}.name`)}
  </span>
)}

reports/page.tsx — generate dialog template picker (falls back to tpl.id):

{t.has(`templates.${tpl.id}.name`) ? t(`templates.${tpl.id}.name`) : tpl.id}

Acceptance criteria

  • Report detail page renders even when a template-name message key cannot be resolved — label is simply omitted
  • Error does not reproduce on a clean dev-server start on the branch — confirmed this is a Turbopack HMR staleness artifact, not a real message-loading bug

Notes

  • Requires next-intl v4 t.has() API — already on ^4.8.3
  • TypeScript check: zero new errors introduced (248 pre-existing errors before and after)

…G_MESSAGE crash (closes #420)

- reports/[id]/page.tsx: detail page header (crash site)
- reports/page.tsx: reports list table cell
- reports/page.tsx: generate dialog template picker

Requires next-intl v4 t.has() API, already on ^4.8.3.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same stale-message scenario from #420 will still crash the generate dialog: templates.${tpl.id}.description on reports/page.tsx:308 is unguarded and lives in the same namespace. Could you add the t.has() guard there too (just hide the description when missing)? Everything else looks good.

Add t.has() guard for templates.${tpl.id}.description on reports/page.tsx
to prevent MISSING_MESSAGE crash when a template description key is absent,
matching the same guard already applied to the template name lookup.

Signed-off-by: Maqbool Ahmed <[email protected]>
@Maqbool61
Maqbool61 requested a review from gkhngyk July 15, 2026 12:02
@Maqbool61

Copy link
Copy Markdown
Contributor Author

The same stale-message scenario from #420 will still crash the generate dialog: templates.${tpl.id}.description on reports/page.tsx:308 is unguarded and lives in the same namespace. Could you add the t.has() guard there too (just hide the description when missing)? Everything else looks good.

Done! Added the t.has() guard for templates.${tpl.id}.description in reports/page.tsx — the description now hides silently when the key is missing instead of crashing. Let me know if anything else needs adjusting!

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Description guard added — all template-namespace lookups are now covered. LGTM.

@gkhngyk
gkhngyk merged commit f53a2f7 into ansvisor:main Jul 15, 2026
3 checks passed
@Maqbool61
Maqbool61 deleted the fix/missing-message-template-name branch July 15, 2026 13:23
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.

Report detail page crashes with MISSING_MESSAGE for template name

2 participants