AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Regression: Inconsistent URL Decoding Of Await Params Between Page And GenerateMetadata

Next.js 16.2.0-canary.54 introduced a regression where `await params` returns URL-encoded values in the page component but decoded values in generateMetadata, causing inconsistent behavior for dynamic routes with encoded characters (e.g., %20).

highConfidence 85%NextAffected V>=16.2.0-Canary.54 <16.3.0-Preview.6

Origin Analysis

The regression was likely introduced by PR #90249, which changed the decoding of route params in the generateMetadata context but did not apply the same decoding to the page component's params. This leads to a split path where params are decoded in one entry point (generateMetadata) but left encoded in another (default export).
1. Create a Next.js dynamic route at /products/[productId] with a page that logs `const { productId } = await params` in both the default export and generateMetadata. 2. Navigate to /products/foo%20bar. 3. Observe server logs: page shows raw "foo%20bar" (char codes 102,111,111,37,50,48,98,97,114) while generateMetadata shows decoded "foo bar" (char codes 102,111,111,32,98,97,114).

Fixing Code Block

Edge Case Audit

Applying `decodeURIComponent` globally may affect existing code that expects raw encoded params (e.g., if users pre-decode or rely on the raw format for custom parsing). It may also cause double-decoding if some params are already decoded by another layer, potentially corrupting values containing literal '%' sequences (e.g., '100%25'). Rollback: if this fix introduces regressions, revert to the previous behavior by removing the decoding from the unified function and instead decoding only in generateMetadata to match the page's raw behavior, or vice versa. Thorough testing across all dynamic route scenarios is required.

Ecosystem Topology