gatsbyjs/gatsby · error

URI malformatted

Error message

URI malformatted

What it means

develop-process installs an express middleware that decodes each request path; a URIError from decodeURIComponent means the URL contains malformed percent-encoding (e.g. a stray %), which is answered with a 500 text response instead of crashing the dev server.

Source

Thrown at packages/gatsby/src/commands/develop-process.ts:130

  const hostname = program.host
  try {
    program.port = await detectPortInUseAndPrompt(port, hostname)
  } catch (e) {
    if (e.message === `USER_REJECTED`) {
      process.exit(0)
    }

    throw e
  }

  const app = express()
  const parentSpan = tracer.startSpan(`bootstrap`)

  app.use((req, res, next) => {
    try {
      decodeURIComponent(req.path)
    } catch (e) {
      return res.status(500).send(`URI malformatted`)
    }

    return next()
  })

  const machine = developMachine.withContext({
    program,
    parentSpan,
    app,
    reporter,
    pendingQueryRuns: new Set([`/`]),
    shouldRunInitialTypegen: true,
  })

  const service = interpret(machine)

  if (program.verbose) {
    logTransitions(service)

View on GitHub (pinned to e85d62f177)

Solutions

  1. Fix malformed percent-encoding in the requested URL
  2. Encode dynamic path segments with encodeURIComponent before navigating
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/gatsby/src/commands/develop-process.ts:130 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/ab5b132ac1c4290a. Report an issue: GitHub.