Skip to content

fix(error-page): render gracefully when panel prop is missing - #5

Merged
maherelgamil merged 1 commit into
mainfrom
fix/error-page-missing-panel
May 28, 2026
Merged

fix(error-page): render gracefully when panel prop is missing#5
maherelgamil merged 1 commit into
mainfrom
fix/error-page-missing-panel

Conversation

@maherelgamil

Copy link
Copy Markdown
Contributor

Summary

The error page (resources/js/pages/error.tsx) assumed panel was always provided. When a 500 is thrown outside the panel middleware stack — or before RenderMonorailErrorPages has had a chance to inject panel data — the page receives panel === undefined and crashes at:

```ts
const __ = create__(panel.translations ?? {});
// ^^^^^ TypeError: Cannot read properties of undefined
```

The React render error then masks the actual server error, making the underlying 500 hard to diagnose.

Fix

  • Make the panel prop optional.
  • Use panel?.translations and panel?.path with sane fallbacks.
  • When panel is missing, skip PanelShell (which strictly requires it) and render a centered standalone layout so the status, title, and message still reach the user.

Reproduction

  1. Hit any route that 500s outside the panel scope (e.g., a missing controller for /opportunities).
  2. Inertia renders the Monorail error page without a panel prop.
  3. Without this fix: white screen + console TypeError: Cannot read properties of undefined (reading 'translations').
  4. With this fix: standalone error card with status code, title, message, and a link to /.

Test plan

  • Trigger a 500 outside /admin and confirm the error page renders
  • Trigger a 404 inside /admin and confirm panel shell still wraps the error (no regression)

The error page assumed `panel` was always provided, but a 500 thrown
outside the panel middleware stack (or before `RenderMonorailErrorPages`
injects the panel data) arrives with `panel === undefined`. The page then
crashed at `panel.translations`, masking the original server error with a
React render error.

Make `panel` optional, fall back to safe defaults, and render a standalone
centered layout when the panel shell can't be used.
@maherelgamil
maherelgamil merged commit 0724f09 into main May 28, 2026
9 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.

1 participant