fix(seo): wrap remaining generateMetadata notFound() calls in try/catch#18006
Merged
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
wackerow
approved these changes
Apr 22, 2026
Member
wackerow
left a comment
There was a problem hiding this comment.
@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!
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Two remaining
generateMetadatafunctions ondevstill callnotFound()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 twonotFound()calls (invalid slug + invalid enum). Not in the current Ahrefs export (category slugs come fromgenerateStaticParams, so misses are rare), but the bug class is identical and worth closing while we're here.The main
Page()functions keep their existingnotFound()calls untouched — they handle the actual 404 HTTP status correctly. OnlygenerateMetadataneeds the fallback.Companion to #17978
PR #17978 (
trailingSEO) applied the same pattern toapp/[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 forgenerateMetadata+notFound()combinations. After both land, a repeat Ahrefs crawl should show the hreflang-to-5xx counts collapse.Test plan