Skip to content

fix(seo): wrap remaining generateMetadata notFound() calls in try/catch#18006

Merged
pettinarip merged 3 commits into
devfrom
fix/dev-tools-category-metadata-502
Apr 23, 2026
Merged

fix(seo): wrap remaining generateMetadata notFound() calls in try/catch#18006
pettinarip merged 3 commits into
devfrom
fix/dev-tools-category-metadata-502

Conversation

@pettinarip
Copy link
Copy Markdown
Member

Summary

Two remaining generateMetadata functions on dev still call notFound() directly, which in Netlify's serverless runtime surfaces as a 502 instead of a 404 — poisoning hreflang reports (see Ahrefs export from 2026-04-17, 335 pages flagged with "Some pages are not returning 200 status code"). This patches both:

  • app/[locale]/developers/tools/[category]/page.tsx — wraps the category-slug validation in try/catch, falls back to basic "page not found" metadata. Directly explains the 3 /developers/tools/.../?toolId=… 502s in the Ahrefs export.
  • app/[locale]/apps/categories/[catetgoryName]/page.tsx — same pattern applied to the two notFound() calls (invalid slug + invalid enum). Not in the current Ahrefs export (category slugs come from generateStaticParams, so misses are rare), but the bug class is identical and worth closing while we're here.

The main Page() functions keep their existing notFound() calls untouched — they handle the actual 404 HTTP status correctly. Only generateMetadata needs the fallback.

Companion to #17978

PR #17978 (trailingSEO) applied the same pattern to app/[locale]/apps/[application]/page.tsx, which accounts for the bulk of the 502 cascade (all /apps/[slug]/ URLs). This PR closes the remaining gaps I found while sweeping the codebase for generateMetadata + notFound() combinations. After both land, a repeat Ahrefs crawl should show the hreflang-to-5xx counts collapse.

Test plan

  • CI green (typecheck + lint pass locally)
  • Hit an invalid dev-tools category slug in a preview deploy — confirm 404, not 502
  • Hit an invalid apps category slug in a preview deploy — confirm 404, not 502
  • After merge + deploy, re-run Ahrefs crawl and confirm hreflang-to-5xx count drops

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 21, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 4662921
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69ea25b14b23520008ad1438
😎 Deploy Preview https://deploy-preview-18006.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 55 (🔴 down 3 from production)
Accessibility: 93 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

@pettinarip Looks good! I believe we should be able to preserve the locale though instead of forcing English. Suggestions below, let me know if you disagree -- otherwise good to merge!

Comment thread app/[locale]/apps/categories/[catetgoryName]/page.tsx Outdated
Comment thread app/[locale]/developers/tools/[category]/page.tsx Outdated
Drop the explicit `locale: DEFAULT_LOCALE` in the try/catch fallbacks:
next-intl's `getRequestConfig` builds the messages map once per request
from `requestLocale`, so passing an explicit locale to `getTranslations`
only changes the formatting locale, not which strings are returned. The
fallback was already rendering the request locale's strings -- this makes
the code honest about that and preserves the user's language for the
`page-not-found` copy.
@pettinarip pettinarip merged commit b5dd2b4 into dev Apr 23, 2026
15 checks passed
@pettinarip pettinarip deleted the fix/dev-tools-category-metadata-502 branch April 23, 2026 14:24
@wackerow wackerow mentioned this pull request Apr 24, 2026
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.

2 participants