vercel/next.js · error · InstantValidationError

Expected sample param value for segment '${rawSegment}' to b

Error message

Expected sample param value for segment '${rawSegment}' to be an array of strings, got ${typeof paramValue}

What it means

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.

Source

Thrown at packages/next/src/server/app-render/instant-validation/instant-samples.ts:431

 */
function createPathnameFromRouteAndSampleParams(route: string, params: Params) {
  let interpolatedSegments: string[] = []
  const rawSegments = route.split('/')
  for (const rawSegment of rawSegments) {
    const param = getSegmentParam(rawSegment)
    if (param) {
      switch (param.paramType) {
        case 'catchall':
        case 'optional-catchall': {
          let paramValue = params[param.paramName]
          if (paramValue === undefined) {
            // The value for the param was not provided. `usePathname` will detect this and throw
            // before this can surface to userspace. Use `[...NAME]` as a placeholder for the param value
            // in case it pops up somewhere unexpectedly.
            paramValue = [rawSegment]
          } else if (!Array.isArray(paramValue)) {
            // NOTE: this happens outside of render, so we don't need `trackMissingSampleErrorAndThrow`
            throw new InstantValidationError(
              `Expected sample param value for segment '${rawSegment}' to be an array of strings, got ${typeof paramValue}`
            )
          }
          interpolatedSegments.push(
            ...paramValue.map((v) => encodeURIComponent(v))
          )
          break
        }
        case 'dynamic': {
          let paramValue = params[param.paramName]
          if (paramValue === undefined) {
            // The value for the param was not provided. `usePathname` will detect this and throw
            // before this can surface to userspace. Use `[NAME]` as a placeholder for the param value
            // in case it pops up somewhere unexpectedly.
            paramValue = rawSegment
          } else if (typeof paramValue !== 'string') {
            // NOTE: this happens outside of render, so we don't need `trackMissingSampleErrorAndThrow`
            throw new InstantValidationError(

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Change the catch-all param value in the sample to an array of strings.
  2. For optional catch-all, you may omit the param entirely, but if provided it must be an array.
  3. Double-check the route's segment type ([...name] => array) and match the sample shape accordingly.
  4. Use the param name exactly as derived by getSegmentParam (strip the bracket syntax).

Example fix

// before (route: /shop/[...slug])
// unstable_samples: { params: { slug: 'a/b' } }

// after
// unstable_samples: { params: { slug: ['a', 'b'] } }
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate catch-all sample param shape before build.
function assertCatchAllArray(paramValue: unknown, name: string) {
  if (paramValue !== undefined && !Array.isArray(paramValue)) {
    throw new Error(`param '${name}' must be an array of strings for catch-all`)
  }
}

Type guard

function isStringArray(v: unknown): v is string[] {
  return Array.isArray(v) && v.every((x) => typeof x === 'string')
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/0ef28cb0a1d4d05c. Report an issue: GitHub.