{"record":{"id":"7ed0d337a619c32f","repo":"vercel/next.js","slug":"expected-sample-param-value-for-segment-rawsegm-7ed0d3","errorCode":null,"errorMessage":"Expected sample param value for segment '${rawSegment}' to be a string, got ${typeof paramValue}","messagePattern":"Expected sample param value for segment '(.+?)' to be a string, got (.+?)","errorType":"validation","errorClass":"InstantValidationError","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/app-render/instant-validation/instant-samples.ts","lineNumber":449,"sourceCode":"            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(\n              `Expected sample param value for segment '${rawSegment}' to be a string, got ${typeof paramValue}`\n            )\n          }\n          interpolatedSegments.push(encodeURIComponent(paramValue))\n          break\n        }\n        case 'catchall-intercepted-(..)(..)':\n        case 'catchall-intercepted-(.)':\n        case 'catchall-intercepted-(..)':\n        case 'catchall-intercepted-(...)':\n        case 'dynamic-intercepted-(..)(..)':\n        case 'dynamic-intercepted-(.)':\n        case 'dynamic-intercepted-(..)':\n        case 'dynamic-intercepted-(...)': {\n          // TODO(instant-validation-build): i don't know how these are supposed to work, or if we can even get them here\n          throw new InvariantError(\n            'Not implemented: Validation of interception routes'\n          )","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/app-render/instant-validation/instant-samples.ts#L431-L467","documentation":"An InstantValidationError from createPathnameFromRouteAndSampleParams() when interpolating a single dynamic segment ([id]). The sample provides a param value that is not a string (e.g. a number or array). Dynamic segments must map to a single string in the sample.","triggerScenarios":"During instant validation, the route has a [name] segment and the sample's params object maps name to a non-string. The typeof paramValue !== 'string' check throws.","commonSituations":"Providing a numeric id in the sample (params: { id: 123 }) instead of a string; accidentally using an array meant for a catch-all route; serializing an object as the param value.","solutions":["Provide a string value for the dynamic param in the sample.","If the id is numeric in your app, still represent it as a string in the sample.","Verify the segment is a single dynamic segment ([id]) not a catch-all, and shape the value accordingly.","Ensure the sample params object values match each segment's required type."],"exampleFix":"// before (route: /posts/[id])\n// unstable_samples: { params: { id: 123 } }\n\n// after\n// unstable_samples: { params: { id: '123' } }","handlingStrategy":"type-guard","validationCode":"// Validate dynamic-segment sample param shape before build.\nfunction assertDynamicString(paramValue: unknown, name: string) {\n  if (paramValue !== undefined && typeof paramValue !== 'string') {\n    throw new Error(`param '${name}' must be a string for a dynamic segment`)\n  }\n}","typeGuard":"function isString(v: unknown): v is string {\n  return typeof v === 'string'\n}","tryCatchPattern":null,"preventionTips":["Provide dynamic-segment params as strings (quote numeric ids).","Match sample param shapes to the route segment types ([name] => string).","Review samples config when adding dynamic routes.","Type your samples config to prevent accidental type mismatches."],"tags":["instant-validation","samples","params","dynamic-segment","build"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}