{"record":{"id":"b699638ac3cb2494","repo":"vercel/next.js","slug":"routes-cannot-be-empty","errorCode":null,"errorMessage":"--routes cannot be empty","messagePattern":"--routes cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bench/render-pipeline/benchmark.ts","lineNumber":136,"sourceCode":"      '/dashboard',\n      '/docs',\n      '/blog',\n      '/streaming/light',\n      '/streaming/medium',\n      '/streaming/heavy',\n      '/streaming/chunkstorm',\n      '/streaming/wide',\n      '/streaming/bulk',\n    ]\n  }\n\n  const routes = rawRoutes\n    .split(',')\n    .map((route) => route.trim())\n    .filter(Boolean)\n\n  if (routes.length === 0) {\n    throw new Error('--routes cannot be empty')\n  }\n\n  for (const route of routes) {\n    if (!route.startsWith('/')) {\n      throw new Error(`Each route must start with '/': ${route}`)\n    }\n  }\n\n  return routes\n}\n\nfunction usage() {\n  console.log(`Usage: pnpm bench:render-pipeline [options]\n\nOptions:\n  --scenario=e2e|minimal-server                  (default: e2e)\n    e2e:            Real production server (next build + next start).\n    minimal-server: NextServer with minimalMode, no router-server.","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/bench/render-pipeline/benchmark.ts#L118-L154","documentation":"Thrown by parseRoutes (benchmark.ts:136) when --routes was provided but, after splitting on commas, trimming, and filtering falsy entries, the list is empty. The default route suite (lines 114-127) is only used when --routes is omitted entirely; an explicit but empty --routes is treated as a user error rather than silently falling back to defaults.","triggerScenarios":"Passing `--routes=` (empty string -> split yields [''] -> filter(Boolean) yields []), or `--routes=,,,` (only commas/whitespace), or `--routes=\" \"`. Omitting --routes is fine and uses defaults.","commonSituations":"A shell variable that was empty expanded into --routes=; a CI script templating routes from an unset env var; user assuming --routes= means 'use defaults'.","solutions":["Omit --routes entirely to use the built-in stress suite, or provide at least one route like --routes=/.","If templating from an env var, guard it: only add --routes when the var is non-empty.","Check for stray commas or whitespace-only values.","Confirm each entry is a path you intend to benchmark."],"exampleFix":"# before\n#   pnpm bench:render-pipeline --routes=\"$ROUTES\"   # with ROUTES unset\n\n# after\nif [ -n \"$ROUTES\" ]; then\n  pnpm bench:render-pipeline --routes=\"$ROUTES\"\nelse\n  pnpm bench:render-pipeline   # use built-in defaults\nfi","handlingStrategy":"validation","validationCode":"function nonEmptyRoutesArg(raw: string | undefined): string[] | undefined {\n  if (raw === undefined) return undefined // use defaults\n  const routes = raw.split(',').map((r) => r.trim()).filter(Boolean)\n  if (routes.length === 0) throw new Error('--routes parsed to empty; omit the flag to use defaults')\n  return routes\n}","typeGuard":"function isNonEmptyRouteList(raw: string | undefined): boolean {\n  if (raw === undefined) return true\n  return raw.split(',').map((r) => r.trim()).filter(Boolean).length > 0\n}","tryCatchPattern":"try {\n  const routes = parseRoutes(args.get('routes'))\n} catch (err) {\n  if ((err as Error).message === '--routes cannot be empty') {\n    console.error('Pass at least one route (e.g. --routes=/) or omit --routes to use defaults.')\n    process.exit(2)\n  }\n  throw err\n}","preventionTips":["Omit --routes to use the built-in suite; only set it when you want a custom list.","Guard shell templates: only add --routes when the variable is non-empty.","Avoid stray commas/whitespace-only entries.","Confirm at least one real route is in the list before running."],"tags":["cli","argument-parsing","routes","validation","render-pipeline"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}