{"record":{"id":"4eef2eca426be5c3","repo":"apify/crawlee","slug":"route-not-found-for-label-string-label-you","errorCode":null,"errorMessage":"Route not found for label '${String(label)}'. You must set up a route for this label or a default route. Use `requestHandler`, `router.addHandler` or `router.addDefaultHandler`.","messagePattern":"Route not found for label '(.+?)'\\. You must set up a route for this label or a default route\\. Use `requestHandler`, `router\\.addHandler` or `router\\.addDefaultHandler`\\.","errorType":"exception","errorClass":"MissingRouteError","httpStatus":null,"severity":"error","filePath":"packages/core/src/router.ts","lineNumber":410,"sourceCode":"     * The crawler needs an upper bound up front, before it knows which routes a run will actually hit.\n     */\n    getMaxTimeoutSecs(): number | undefined {\n        return this.#timeouts.size > 0 ? Math.max(...this.#timeouts.values()) : undefined;\n    }\n\n    /**\n     * Returns route handler for given label. If no label is provided, the default request handler will be returned.\n     */\n    getHandler(label?: string | symbol): (ctx: Context) => Awaitable<void> {\n        if (label && this.#routes.has(label)) {\n            return this.#routes.get(label)!;\n        }\n\n        if (this.#routes.has(defaultRoute)) {\n            return this.#routes.get(defaultRoute)!;\n        }\n\n        throw new MissingRouteError(\n            `Route not found for label '${String(label)}'.` +\n                ' You must set up a route for this label or a default route.' +\n                ' Use `requestHandler`, `router.addHandler` or `router.addDefaultHandler`.',\n        );\n    }\n\n    /**\n     * Validates `request.userData` against the schema registered for its label (if any), replacing it with\n     * the parsed value. Throws a {@apilink RequestValidationError} when validation fails.\n     */\n    private async validateRequest(context: Context) {\n        const label = context.request.label;\n        const schema = this.getSchema(label);\n\n        if (schema) {\n            context.request.userData = (await validateUserData(\n                label!,\n                schema,","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/router.ts#L392-L428","documentation":"Router.getHandler looks up the route registered for the request's label (or the default route) and throws MissingRouteError when neither exists. The router refuses to handle requests it has no handler for, rather than silently dropping them.","triggerScenarios":"Dispatching a request whose userData.label has no matching addHandler(label, ...) registration and no addDefaultHandler(...) was configured.","commonSituations":"Typo or casing mismatch between the label used when enqueuing and the one registered; label added in one environment but not another; refactoring removed a handler while old queued requests still reference it; forgetting a default catch-all handler.","solutions":["Register the missing route with router.addHandler(label, handler)","Add router.addDefaultHandler(handler) as a catch-all","Verify the label on the failing request exactly matches a registered label (string vs symbol, case)","Audit queued/persisted requests for labels of removed routes"],"exampleFix":"// before\nrouter.addHandler('product', handler);\n// request with label 'Product' -> MissingRouteError\n// after\nrouter.addHandler('product', handler);\nrouter.addDefaultHandler(defaultHandler);","handlingStrategy":"try-catch","validationCode":"const label = request.userData?.label;\nif (label !== undefined && !registeredLabels.has(label)) {\n  throw new Error(`No route registered for label: ${String(label)}`);\n}","typeGuard":"function hasRoute(router: Router, label: string): boolean {\n  return router.getHandler; // check via a non-throwing lookup if exposed, else keep a Set of registered labels\n}","tryCatchPattern":"try {\n  handler = router.getHandler(label);\n} catch (err) {\n  if (err.name === 'MissingRouteError') {\n    handler = fallbackHandler;\n  } else throw err;\n}","preventionTips":["Always register a default handler with addDefaultHandler","Centralize label constants to avoid typos","When removing a route, purge or remap queued requests using its label","Log unknown labels during development"],"tags":["routing","configuration","request"],"backgroundTag":"missing-route-handler","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}