Skip to content

fix(landing): resolve error-page crash on invalid /models and /integrations routes#4243

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/moab-v1
Apr 21, 2026
Merged

fix(landing): resolve error-page crash on invalid /models and /integrations routes#4243
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/moab-v1

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Apr 21, 2026

Summary

  • Invalid URLs under /models/* and /integrations/* were rendering "Application error: a client-side exception has occurred" instead of the styled 404.
  • Root cause is a React/Next.js interaction: React skips SSR on server errors and re-renders on the client (React 18 RFC, vercel/next.js#63980, #82456). Root-layout scripts — including the runtime env script that populates window.__ENV — get inserted into the DOM but are not executed on that client re-render. Any client module that reads env at module evaluation (lib/auth/auth-client.tsgetBaseUrl()) throws and cascades the render into the error overlay.

Changes

  1. lib/auth/auth-client.ts — fall back to window.location.origin when getBaseUrl() throws on the client. Auth endpoints are same-origin, so this is the correct baseURL on the client. Server-side still throws on genuine misconfig, so webhooks/callbacks continue to surface misconfiguration loudly.
  2. Three loading.tsx files at /models/[provider], /models/[provider]/[model], and /integrations/[slug] — establishes a Suspense boundary below the root layout so a page-level notFound() stops invalidating the layout's SSR output. This is the fix endorsed by Next.js maintainer lubieowoce in #63980.

Type of Change

  • Bug fix

Testing

Tested manually — invalid /models/* and /integrations/* URLs now render the styled 404 without the client-side exception overlay. Valid pages unchanged.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 21, 2026 7:29pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 21, 2026

PR Summary

Medium Risk
Touches auth client initialization by changing how baseURL is derived; mistakes could break sign-in flows or point auth calls at the wrong origin. The new loading.tsx Suspense boundaries are low risk but affect route rendering behavior.

Overview
Fixes a landing-page crash where invalid /models/* and /integrations/* URLs could trigger a client-side exception instead of the styled 404.

Updates lib/auth/auth-client.ts to compute the auth baseURL via getAuthBaseUrl(), falling back to window.location.origin on the client when getBaseUrl() throws (while still surfacing misconfiguration on the server).

Adds loading.tsx to the /models/[provider], /models/[provider]/[model], and /integrations/[slug] routes to introduce a lower-level Suspense boundary, preventing server errors/notFound() from invalidating the root layout render.

Reviewed by Cursor Bugbot for commit 51b5ee9. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR fixes a client-side crash on invalid /models/* and /integrations/* routes by (1) adding a fallback to window.location.origin in getAuthBaseUrl() when window.__ENV is not populated during client-side re-render, and (2) adding loading.tsx files to establish Suspense boundaries so page-level notFound() no longer invalidates the root layout's SSR output.

Confidence Score: 5/5

Safe to merge — targeted, well-scoped bug fix with no new risk surface.

All four changed files are correct and minimal. The auth fallback only activates on the client when the env script hasn't run (the exact crash scenario), and the server-side path still throws on genuine misconfiguration. The loading.tsx files are boilerplate Suspense boundaries that follow existing project patterns. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/auth/auth-client.ts Adds getAuthBaseUrl() wrapper that falls back to window.location.origin on the client when getBaseUrl() throws due to missing window.__ENV; server-side behaviour preserved.
apps/sim/app/(landing)/integrations/[slug]/loading.tsx New loading.tsx establishing a Suspense boundary for the integration detail route; minimal and correct.
apps/sim/app/(landing)/models/[provider]/loading.tsx New loading.tsx establishing a Suspense boundary for the model provider route; minimal and correct.
apps/sim/app/(landing)/models/[provider]/[model]/loading.tsx New loading.tsx establishing a Suspense boundary for the model detail route; minimal and correct.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant NextJS as Next.js (SSR)
    participant RootLayout as Root Layout
    participant Page as [slug]/page.tsx
    participant Loading as [slug]/loading.tsx (new)

    Browser->>NextJS: GET /models/invalid-provider
    NextJS->>RootLayout: Render layout (runs env script)
    RootLayout->>Loading: Render Suspense boundary (loading.tsx)
    Loading-->>Browser: Show spinner immediately
    NextJS->>Page: Render page → notFound() thrown
    Note over Page,Loading: notFound() is caught at Suspense boundary,<br/>not propagated to root layout
    Page-->>Browser: Render styled 404 page

    Note over Browser,Loading: Before fix: notFound() escaped Suspense,<br/>invalidated SSR, client re-render skipped env script,<br/>getBaseUrl() threw → crash overlay
Loading

Reviews (3): Last reviewed commit: "improvement(landing): use emcn Loader in..." | Re-trigger Greptile

React skips SSR on unhandled server errors and re-renders on the client
(see vercel/next.js#63980, #82456). Root-layout scripts — including the
runtime env script that populates window.__ENV — are inserted but not
executed on that client re-render, so any client module that reads env
at module evaluation crashes the render into a blank "Application error"
overlay instead of rendering the styled 404.

This replaces the earlier PublicEnvScript tweak with the architectural
fix:

- auth-client.ts: fall back to window.location.origin when getBaseUrl()
  throws on the client. Auth endpoints are same-origin, so this is the
  correct baseURL on the client. Server-side we still throw on genuine
  misconfig.
- loading.tsx under /models/[provider], /models/[provider]/[model], and
  /integrations/[slug]: establishes a Suspense boundary below the root
  layout so a page-level notFound() no longer invalidates the layout's
  SSR output (the fix endorsed by Next.js maintainers in #63980).
- layout.tsx: revert disableNextScript — the research showed this
  doesn't actually fix error-page renders. The real fix is above.
@waleedlatif1 waleedlatif1 changed the title fix(layout): use plain inline script for PublicEnvScript to set env before chunks eval on error pages fix(landing): resolve error-page crash on invalid /models and /integrations routes Apr 21, 2026
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7dfbe69. Configure here.

…h-client comment

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 51b5ee9. Configure here.

@waleedlatif1 waleedlatif1 merged commit 42ef2b1 into staging Apr 21, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/moab-v1 branch April 21, 2026 19:43
waleedlatif1 added a commit that referenced this pull request Apr 21, 2026
…ations routes (#4243)

* fix(layout): use plain inline script for PublicEnvScript to set env before chunks eval on error pages

* fix(landing): handle runtime env race on error-page renders

React skips SSR on unhandled server errors and re-renders on the client
(see vercel/next.js#63980, #82456). Root-layout scripts — including the
runtime env script that populates window.__ENV — are inserted but not
executed on that client re-render, so any client module that reads env
at module evaluation crashes the render into a blank "Application error"
overlay instead of rendering the styled 404.

This replaces the earlier PublicEnvScript tweak with the architectural
fix:

- auth-client.ts: fall back to window.location.origin when getBaseUrl()
  throws on the client. Auth endpoints are same-origin, so this is the
  correct baseURL on the client. Server-side we still throw on genuine
  misconfig.
- loading.tsx under /models/[provider], /models/[provider]/[model], and
  /integrations/[slug]: establishes a Suspense boundary below the root
  layout so a page-level notFound() no longer invalidates the layout's
  SSR output (the fix endorsed by Next.js maintainers in #63980).
- layout.tsx: revert disableNextScript — the research showed this
  doesn't actually fix error-page renders. The real fix is above.

* improvement(landing): use emcn Loader in scoped loading.tsx, trim auth-client comment

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
waleedlatif1 added a commit that referenced this pull request Apr 21, 2026
…S/CloudWatch/DynamoDB (#4245)

* feat(integrations): add AWS SES, IAM Identity Center, and enhanced IAM/STS/CloudWatch/DynamoDB integrations

- Add AWS SES v2 integration with 9 operations (send email, templated, bulk, templates, account)
- Add AWS IAM Identity Center integration with 12 operations (account assignments, permission sets, users, groups)
- Add 3 new IAM tools: list-attached-role-policies, list-attached-user-policies, simulate-principal-policy
- Fix DynamoDB duplicate subBlock IDs, add operation-scoped field names, add subblock migrations
- Add authMode: AuthMode.ApiKey to DynamoDB block
- Fix CloudWatch routes: toError, client.destroy(), withRouteHandler, auth outside try
- Fix STS/DynamoDB/IAM routes: nullable Zod schemas, withRouteHandler adoption
- Fix Identity Center: list_instances pagination, list_groups instanceArn condition
- Add subblock migrations for renamed DynamoDB fields (key, filterExpression, etc.)
- Apply withRouteHandler to all new and existing AWS tool routes

* docs(ses): add manual intro section to SES docs

* fix(dynamodb): add legacy fallbacks in params for subblock migration compatibility

Workflows saved with the old shared IDs (key, filterExpression, etc.) that migrate
to get-scoped slots via subblock-migrations still work correctly on update/delete/scan/put
operations via fallback lookups in tools.config.params.

* feat(contact): add contact page, migrate help/demo forms to useMutation (#4242)

* feat(contact): add contact page, migrate help/demo forms to useMutation

* improvement(contact): address greptile review feedback

- Map contact topic to help email type for accurate confirmation emails
- Drop Zod schema details from 400 response on public /api/contact
- Wire aria-describedby + aria-invalid in LandingField for both forms
- Reset helpMutation on modal reopen to match demo-request pattern

* improvement(landing): extract shared LandingField component

* fix(landing): resolve error-page crash on invalid /models and /integrations routes (#4243)

* fix(layout): use plain inline script for PublicEnvScript to set env before chunks eval on error pages

* fix(landing): handle runtime env race on error-page renders

React skips SSR on unhandled server errors and re-renders on the client
(see vercel/next.js#63980, #82456). Root-layout scripts — including the
runtime env script that populates window.__ENV — are inserted but not
executed on that client re-render, so any client module that reads env
at module evaluation crashes the render into a blank "Application error"
overlay instead of rendering the styled 404.

This replaces the earlier PublicEnvScript tweak with the architectural
fix:

- auth-client.ts: fall back to window.location.origin when getBaseUrl()
  throws on the client. Auth endpoints are same-origin, so this is the
  correct baseURL on the client. Server-side we still throw on genuine
  misconfig.
- loading.tsx under /models/[provider], /models/[provider]/[model], and
  /integrations/[slug]: establishes a Suspense boundary below the root
  layout so a page-level notFound() no longer invalidates the layout's
  SSR output (the fix endorsed by Next.js maintainers in #63980).
- layout.tsx: revert disableNextScript — the research showed this
  doesn't actually fix error-page renders. The real fix is above.

* improvement(landing): use emcn Loader in scoped loading.tsx, trim auth-client comment

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>

* fix(iam): correct MissingContextValues mapping in simulatePrincipalPolicy

* fix(aws): add conditionExpression migration fallback for DynamoDB delete, fix SES pageSize min

* fix(aws): deep validation fixes across SES, IAM, Identity Center, DynamoDB integrations

- IAM: replace non-existent StatementId with SourcePolicyType in simulatePrincipalPolicy
- IAM: add .int() constraint to list-users/roles/policies/groups Zod schemas
- IAM: remove redundant manual requestId from all 21 IAM route handlers
- SES: add .refine() body validation to create-template route
- SES: make bulk email destination templateData optional, only include ReplacementEmailContent when present
- SES: fix pageSize guard to if (pageSize != null) to correctly forward 0
- SES: add max(100) to list-templates pageSize, revert list-identities to min(0) per SDK
- STS: fix logger.error calls to use structured metadata pattern
- Identity Center: remove deprecated account.Status fallback, use account.State only
- DynamoDB: convert empty interface extends to type aliases, remove redundant error field, fix barrel to absolute imports

* regen docs

* fix(iam): add .int() constraint to maxSessionDuration in create-role route

* fix(ses): forward pageSize=0 correctly in listIdentities util

* fix(aws): add gradient background to IdentityCenterIcon, fix listTemplates pageSize guard

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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