Skip to content

fix(chat): fail-safe to noindex if the deployment lookup errors#5396

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix-chat-metadata-db-error
Jul 3, 2026
Merged

fix(chat): fail-safe to noindex if the deployment lookup errors#5396
waleedlatif1 merged 1 commit into
stagingfrom
fix-chat-metadata-db-error

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Cursor Bugbot flagged on fix(seo): fix GSC indexing issues, remove unused academy/partners pages #5388 (already merged): the chat page's generateMetadata DB lookup had no error handling, unlike the identical query in api/chat/[identifier]/route.ts which already wraps it in try/catch
  • Verified this is real: there's no error.tsx under app/(interfaces)/chat/, and Next.js docs confirm generateMetadata resolves outside the rendered tree that route-segment error boundaries wrap — only the root global-error.tsx would catch a throw here, meaning a DB hiccup during this lookup would crash the whole page to a generic error page instead of degrading like the old static-metadata version did
  • Fix: catch the error, log it, default isIndexable = false. This is also just the correct default independent of the bug — if we can't confirm a deployment is safely public, noindex is the right call, not a 500

Type of Change

  • Bug fix

Testing

Tested manually — live dev server, confirmed the success path (noindex, nofollow for a nonexistent identifier) is unchanged. Typecheck and Biome lint pass.

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)

generateMetadata queried the DB with no error handling, unlike the
identical query in api/chat/[identifier]/route.ts (which already wraps
it in try/catch). There's no error.tsx under app/(interfaces)/chat/ —
metadata resolution errors aren't caught by route-segment error
boundaries at all, only the root global-error.tsx — so a DB hiccup
during this lookup would take the whole page down to a generic error
page instead of just failing to determine indexability. Catches the
error, logs it, and defaults to noindex: if we can't confirm the
deployment is safely public, that's the correct SEO default anyway,
not a reason to crash the request.

Flagged by Cursor Bugbot on #5388 (already merged); this ships the fix
as a standalone follow-up since the underlying code is already live.
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 3, 2026 9:16pm

Request Review

@cursor

cursor Bot commented Jul 3, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small defensive change to metadata-only indexing logic with no auth or data-model changes; success path behavior is unchanged.

Overview
Chat generateMetadata no longer lets a failed deployment DB lookup crash the page. The lookup is wrapped in try/catch, errors are logged with identifier and message, and isIndexable stays false so metadata still applies robots: noindex, nofollow when the deployment cannot be confirmed public.

Comments document that this route has no segment error.tsx, so an uncaught throw would surface as a full-page failure instead of a safe SEO default.

Reviewed by Cursor Bugbot for commit 18fa798. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a try/catch around the DB lookup in generateMetadata for the chat page, defaulting isIndexable to false when the query fails. This prevents a DB error from crashing the entire page render since Next.js generateMetadata executes outside the route-segment error boundary.

  • Wraps the Drizzle db.select call in a try/catch; on error, logs via createLogger('ChatMetadata') and falls back to isIndexable = false (noindex/nofollow).
  • Aligns the safety model with the rest of the codebase — the equivalent query in api/chat/[identifier]/route.ts already wraps its lookup in try/catch.

Confidence Score: 5/5

Safe to merge — the change is a pure defensive addition that cannot regress the success path and correctly handles a previously unhandled failure mode.

The diff is a single, well-scoped try/catch block. The success path is unchanged: the DB query, the isIndexable logic, and the returned metadata object are identical to before. The error path is new but conservative — it logs and leaves isIndexable = false, which matches the pre-existing behavior for non-existent or non-public deployments. Logger and utility imports follow the patterns used throughout the codebase.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/(interfaces)/chat/[identifier]/page.tsx Adds try/catch around the generateMetadata DB lookup with a fail-safe noindex default; imports and logger usage follow established codebase patterns.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[generateMetadata called] --> B[await params]
    B --> C[isIndexable = false]
    C --> D{DB lookup}
    D -->|success| E[isIndexable = deployment.isActive && authType === 'public']
    D -->|throws| F[logger.error with identifier + message]
    F --> G[isIndexable remains false]
    E --> H{isIndexable?}
    G --> H
    H -->|true| I[Return title: 'Chat']
    H -->|false| J[Return title: 'Chat' + robots: noindex nofollow]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[generateMetadata called] --> B[await params]
    B --> C[isIndexable = false]
    C --> D{DB lookup}
    D -->|success| E[isIndexable = deployment.isActive && authType === 'public']
    D -->|throws| F[logger.error with identifier + message]
    F --> G[isIndexable remains false]
    E --> H{isIndexable?}
    G --> H
    H -->|true| I[Return title: 'Chat']
    H -->|false| J[Return title: 'Chat' + robots: noindex nofollow]
Loading

Reviews (1): Last reviewed commit: "fix(chat): fail-safe to noindex if the d..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit 2e35744 into staging Jul 3, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the fix-chat-metadata-db-error branch July 3, 2026 21: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.

1 participant