{"record":{"id":"ff268879aa2ad684","repo":"vercel/next.js","slug":"failed-to-decode-param","errorCode":null,"errorMessage":"failed to decode param","messagePattern":"failed to decode param","errorType":"exception","errorClass":"DecodeError","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/dev/hot-reloader-webpack.ts","lineNumber":384,"sourceCode":"    // and then the bundle will be served like usual by the actual route in server/index.js\n    const handlePageBundleRequest = async (\n      pageBundleRes: ServerResponse,\n      parsedPageBundleUrl: UrlObject\n    ): Promise<{ finished?: true }> => {\n      const { pathname } = parsedPageBundleUrl\n      if (!pathname) return {}\n\n      const params = matchNextPageBundleRequest(pathname)\n      if (!params) return {}\n\n      let decodedPagePath: string\n\n      try {\n        decodedPagePath = `/${params.path\n          .map((param: string) => decodeURIComponent(param))\n          .join('/')}`\n      } catch (_) {\n        throw new DecodeError('failed to decode param')\n      }\n\n      const page = denormalizePagePath(decodedPagePath)\n\n      if (page === '/_error' || BLOCKED_PAGES.indexOf(page) === -1) {\n        try {\n          await this.ensurePage({ page, clientOnly: true, url: req.url })\n        } catch (error) {\n          return await renderScriptError(pageBundleRes, getProperError(error))\n        }\n\n        const errors = await this.getCompilationErrors(page)\n        if (errors.length > 0) {\n          return await renderScriptError(pageBundleRes, errors[0], {\n            verbose: false,\n          })\n        }\n      }","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/hot-reloader-webpack.ts#L366-L402","documentation":"Thrown as a DecodeError when decodeURIComponent fails on any path segment of a requested page bundle. The webpack hot reloader splits the bundle URL into params and decodeURIComponent-maps each segment; a malformed percent-encoding sequence (e.g. a lone '%' or incomplete multibyte escape) makes decodeURIComponent throw, which is converted into DecodeError('failed to decode param'). This breaks serving that particular page bundle in dev.","triggerScenarios":"A request to /_next/static/<buildid>/pages/<segments>.js where one segment contains an invalid percent-encoded sequence such as '%zz', '%E0%A4', or a raw percent sign. decodeURIComponent throws and is caught and rethrown as DecodeError.","commonSituations":"A proxy/CDN rewrites or truncates URLs, producing broken percent escapes. A bot or scanner requests a malformed _next path. A route/page name contains characters that get mis-encoded by a reverse proxy. Custom middleware that rewrites the URL incorrectly.","solutions":["Inspect the failing request URL (server logs) for stray '%' or truncated escape sequences and fix the client/proxy generating it.","If a reverse proxy is re-encoding the path, configure it to pass URLs through unchanged.","Use URL-encoding-safe page names (avoid special characters in page filenames).","Reproduce with curl using the exact URL to confirm the malformed segment, then correct the source of the request."],"exampleFix":"# before (malformed percent escape)\ncurl '/_next/static/dev/pages/%E0%A4.js'\n\n# after (properly encoded path)\ncurl '/_next/static/dev/pages/about.js'","handlingStrategy":"try-catch","validationCode":"// Reject malformed percent-encoding before it reaches the page-bundle handler\nfunction isSafeEncodedPath(segments: string[]): boolean {\n  for (const seg of segments) {\n    try { decodeURIComponent(seg) } catch { return false }\n  }\n  return true\n}","typeGuard":null,"tryCatchPattern":"try {\n  decodedPagePath = '/' + params.path.map((p: string) => decodeURIComponent(p)).join('/')\n} catch {\n  throw new DecodeError('failed to decode param')\n}","preventionTips":["Don't generate internal _next URLs client-side; let Next.js emit them.","Configure reverse proxies to forward paths verbatim (no double-encoding).","Use encodeURIComponent consistently if you must construct such URLs."],"tags":["webpack","url-encoding","dev-server","routing"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T01:17:05.418Z"}