remix-run/remix · error · Error
Route-map loader returned an invalid route leaf for "${name}
Error message
Route-map loader returned an invalid route leaf for "${name}". What it means
For 'route' kind nodes, `method` and `pattern` must both be strings; they define the HTTP route leaf. This is the last leaf-level validation of the worker payload.
Source
Thrown at packages/cli/src/lib/route-map.ts:271
if (!Array.isArray(children)) {
throw new Error(`Route-map loader returned invalid children for "${name}".`)
}
if (kind === 'group') {
return {
children: children.map((child) => assertRawRouteTreeNode(child)),
key,
kind,
name,
}
}
let method = Reflect.get(value, 'method')
let pattern = Reflect.get(value, 'pattern')
if (typeof method !== 'string' || typeof pattern !== 'string') {
throw new Error(`Route-map loader returned an invalid route leaf for "${name}".`)
}
return {
children: [],
key,
kind,
method,
name,
pattern,
}
}
async function findRemixAppRoot(startDir: string): Promise<string> {
let appRoot = await findAppRoot(startDir, 'app/routes.ts')
if (appRoot == null) {
throw routesFileNotFound(startDir)
}View on GitHub (pinned to 9696913134)
Solutions
- Align remix package versions and do a clean install
- Complete route fixtures with string `method` and `pattern` fields
- If it persists on a clean install, report as a CLI bug
Defensive patterns
Strategy: validation
Validate before calling
tree.filter(n => n.kind === 'route').every(n => typeof n.method === 'string' && typeof n.pattern === 'string')
Type guard
function isRouteLeaf(n: unknown): n is { kind: 'route'; method: string; pattern: string } {
let r = n as any
return r?.kind === 'route' && typeof r.method === 'string' && typeof r.pattern === 'string'
} Prevention
- Complete route fixtures with method and pattern
- Avoid partial-upgrade installs that mix schemas
- Smoke-test route loading in CI
When it happens
Trigger: A route node whose method or pattern is missing/non-string, e.g. `{ kind: 'route', name: 'home' }` with no method/pattern — schema drift or incomplete mock data.
Common situations: Fixture authors omitting method/pattern; mixed-version installs where the leaf schema changed between releases.
Related errors
- Route-map loader returned an invalid route node.
- Route-map loader returned a route node without a valid name.
- Route-map loader returned an unknown node kind for "${name}"
- Route-map loader returned invalid children for "${name}".
- Missing app/routes.ts path.
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/bf8b8547c51d21bb.
Report an issue: GitHub.