{"record":{"id":"0ef28cb0a1d4d05c","repo":"vercel/next.js","slug":"expected-sample-param-value-for-segment-rawsegm","errorCode":null,"errorMessage":"Expected sample param value for segment '${rawSegment}' to be an array of strings, got ${typeof paramValue}","messagePattern":"Expected sample param value for segment '(.+?)' to be an array of strings, got (.+?)","errorType":"validation","errorClass":"InstantValidationError","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/app-render/instant-validation/instant-samples.ts","lineNumber":431,"sourceCode":" */\nfunction createPathnameFromRouteAndSampleParams(route: string, params: Params) {\n  let interpolatedSegments: string[] = []\n  const rawSegments = route.split('/')\n  for (const rawSegment of rawSegments) {\n    const param = getSegmentParam(rawSegment)\n    if (param) {\n      switch (param.paramType) {\n        case 'catchall':\n        case 'optional-catchall': {\n          let paramValue = params[param.paramName]\n          if (paramValue === undefined) {\n            // The value for the param was not provided. `usePathname` will detect this and throw\n            // before this can surface to userspace. Use `[...NAME]` as a placeholder for the param value\n            // in case it pops up somewhere unexpectedly.\n            paramValue = [rawSegment]\n          } else if (!Array.isArray(paramValue)) {\n            // NOTE: this happens outside of render, so we don't need `trackMissingSampleErrorAndThrow`\n            throw new InstantValidationError(\n              `Expected sample param value for segment '${rawSegment}' to be an array of strings, got ${typeof paramValue}`\n            )\n          }\n          interpolatedSegments.push(\n            ...paramValue.map((v) => encodeURIComponent(v))\n          )\n          break\n        }\n        case 'dynamic': {\n          let paramValue = params[param.paramName]\n          if (paramValue === undefined) {\n            // The value for the param was not provided. `usePathname` will detect this and throw\n            // before this can surface to userspace. Use `[NAME]` as a placeholder for the param value\n            // in case it pops up somewhere unexpectedly.\n            paramValue = rawSegment\n          } else if (typeof paramValue !== 'string') {\n            // NOTE: this happens outside of render, so we don't need `trackMissingSampleErrorAndThrow`\n            throw new InstantValidationError(","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/app-render/instant-validation/instant-samples.ts#L413-L449","documentation":"An InstantValidationError from createPathnameFromRouteAndSampleParams() when interpolating a catch-all ([...slug]) or optional-catch-all ([[...slug]]) route segment. The sample provides a param value for that segment, but it is not an array of strings (catch-all params are always arrays). This is a samples-config shape error, not a render-time error.","triggerScenarios":"During instant validation, the route contains a catch-all segment and the sample's params object maps that param name to a non-array value (e.g. a string or number). The code checks Array.isArray(paramValue) and throws.","commonSituations":"Defining samples for a [...slug] route but providing params: { slug: 'a/b/c' } (string) instead of ['a','b','c'] (array); copy-pasting a dynamic-segment sample into a catch-all route; JSON config mistakes where the array became a string.","solutions":["Change the catch-all param value in the sample to an array of strings.","For optional catch-all, you may omit the param entirely, but if provided it must be an array.","Double-check the route's segment type ([...name] => array) and match the sample shape accordingly.","Use the param name exactly as derived by getSegmentParam (strip the bracket syntax)."],"exampleFix":"// before (route: /shop/[...slug])\n// unstable_samples: { params: { slug: 'a/b' } }\n\n// after\n// unstable_samples: { params: { slug: ['a', 'b'] } }","handlingStrategy":"type-guard","validationCode":"// Validate catch-all sample param shape before build.\nfunction assertCatchAllArray(paramValue: unknown, name: string) {\n  if (paramValue !== undefined && !Array.isArray(paramValue)) {\n    throw new Error(`param '${name}' must be an array of strings for catch-all`)\n  }\n}","typeGuard":"function isStringArray(v: unknown): v is string[] {\n  return Array.isArray(v) && v.every((x) => typeof x === 'string')\n}","tryCatchPattern":null,"preventionTips":["Always provide catch-all params as arrays of strings in samples.","Match sample param shapes to the route segment types ([...name] => array).","Review samples config when adding catch-all routes.","Use a schema/type for your samples config to catch mistakes."],"tags":["instant-validation","samples","params","catch-all","build"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}