gatsbyjs/gatsby · error · Error

not a valid pageData response

Error message

not a valid pageData response

What it means

Client-side page-data loader: the 200 response for page-data.json parsed as JSON but had no 'path' key, so it is not the expected pageData payload shape — typically a dev server returning HTML or an error document where JSON was expected.

Source

Thrown at packages/gatsby/cache-dir/loader.js:182

  }

  setApiRunner(apiRunner) {
    this.apiRunner = apiRunner
    this.prefetchDisabled = apiRunner(`disableCorePrefetching`).some(a => a)
  }

  fetchPageDataJson(loadObj) {
    const { pagePath, retries = 0 } = loadObj
    const url = createPageDataUrl(pagePath)
    return this.memoizedGet(url).then(req => {
      const { status, responseText } = req

      // Handle 200
      if (status === 200) {
        try {
          const jsonPayload = JSON.parse(responseText)
          if (jsonPayload.path === undefined) {
            throw new Error(`not a valid pageData response`)
          }

          const maybeSearch = pagePath.split(`?`)[1]
          if (maybeSearch && !jsonPayload.path.includes(maybeSearch)) {
            jsonPayload.path += `?${maybeSearch}`
          }

          return Object.assign(loadObj, {
            status: PageResourceStatus.Success,
            payload: jsonPayload,
          })
        } catch (err) {
          // continue regardless of error
        }
      }

      // Handle 404
      if (status === 404 || status === 200) {

View on GitHub (pinned to e85d62f177)

Solutions

  1. Hard-refresh to bust a stale cached page-data response
  2. Clear .cache/public and restart the dev server
  3. Check the dev server log for the actual response served for that page path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby/cache-dir/loader.js:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/84915a3d53f8a202. Report an issue: GitHub.