vercel/next.js · error · InstantValidationError

Expected sample param value for segment

Error message

Expected sample param value for segment '${rawSegment}' to be a string, got ${typeof paramValue}

What it means

Type check while interpolating sample params during instant validation: a dynamic (single) segment's param value was expected to be a plain string but had another type. The faulting input is the samples configuration entry supplying that segment's value.

Solutions

  1. Provide a string for the dynamic segment sample param in instant validation config.
Defensive patterns

Strategy: validation

When it happens

Trigger: A dynamic segment sample param value is not a string.

Common situations: Instant validation sample data provides a non-string value for a single dynamic segment.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/7ed0d337a619c32f. Report an issue: GitHub.

Appendix: source

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

            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(
              `Expected sample param value for segment '${rawSegment}' to be a string, got ${typeof paramValue}`
            )
          }
          interpolatedSegments.push(encodeURIComponent(paramValue))
          break
        }
        case 'catchall-intercepted-(..)(..)':
        case 'catchall-intercepted-(.)':
        case 'catchall-intercepted-(..)':
        case 'catchall-intercepted-(...)':
        case 'dynamic-intercepted-(..)(..)':
        case 'dynamic-intercepted-(.)':
        case 'dynamic-intercepted-(..)':
        case 'dynamic-intercepted-(...)': {
          // TODO(instant-validation-build): i don't know how these are supposed to work, or if we can even get them here
          throw new InvariantError(
            'Not implemented: Validation of interception routes'
          )

View on GitHub (pinned to 0eb3775416)