{"record":{"id":"507e80bc7e94e986","repo":"clockworklabs/SpacetimeDB","slug":"http-router-references-unknown-handler-route-han","errorCode":null,"errorMessage":"HTTP router references unknown handler `{route.HandlerFunction}`","messagePattern":"HTTP router references unknown handler `(.+?)`","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"crates/bindings-csharp/Runtime/Internal/Module.cs","lineNumber":396,"sourceCode":"    {\n        var procedure = ProcedureCache<P>.Instance;\n        moduleDef.RegisterProcedure(procedure.MakeProcedureDef(typeRegistrar));\n    }\n\n    public static void RegisterHttpHandler<H>()\n        where H : IHttpHandler, new()\n    {\n        var handler = HttpHandlerCache<H>.Instance;\n        moduleDef.RegisterHttpHandler(handler.MakeHandlerDef());\n    }\n\n    public static void RegisterHttpRouter(SpacetimeDB.Router router)\n    {\n        foreach (var route in router.GetRoutes())\n        {\n            if (!moduleDef.HasHttpHandler(route.HandlerFunction))\n            {\n                throw new ArgumentException(\n                    $\"HTTP router references unknown handler `{route.HandlerFunction}`\",\n                    nameof(router)\n                );\n            }\n\n            moduleDef.RegisterHttpRoute(\n                new RawHttpRouteDefV10(\n                    HandlerFunction: route.HandlerFunction,\n                    Method: route.Method,\n                    Path: route.Path\n                )\n            );\n        }\n    }\n\n    public static void RegisterTable<T, View>()\n        where T : IStructuralReadWrite, new()\n        where View : ITableView<View, T>, new()","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/bindings-csharp/Runtime/Internal/Module.cs#L378-L414","documentation":"SpacetimeDB's C# Module.RegisterHttpRouter validates each HTTP route before registering it: every route must point at a handler function that actually exists in the module definition (moduleDef.HasHttpHandler). If a route's HandlerFunction name does not match any registered HTTP handler, the router is rejected with this ArgumentException and no routes are registered.","triggerScenarios":"Calling Module.RegisterHttpRouter(router) where router.GetRoutes() yields a route whose HandlerFunction string has no matching handler in the module — e.g. the handler was renamed, deleted, never decorated/registered, or the route table was built against an older module schema.","commonSituations":"Renaming a handler method without updating the route table; typos in the handler name; route definitions generated or deserialized from config that drifted from the actual module code; version mismatch between route registration code and module handlers.","solutions":["Check each route.HandlerFunction name against the handlers your module defines and fix the mismatched name","Register or un-decorate the missing handler so HasHttpHandler returns true for every route","Regenerate/rebuild the router from the current module definitions so route names match the code","Verify module initialization order: handlers must be registered on moduleDef before RegisterHttpRouter is called"],"exampleFix":"// before\nvar router = Router.WithRoute(\"users\", HandlerFunction: \"GetUserLegacy\");\nModule.RegisterHttpRouter(router); // throws: unknown handler `GetUserLegacy`\n// after\nvar router = Router.WithRoute(\"users\", HandlerFunction: \"GetUser\");\nModule.RegisterHttpRouter(router);","handlingStrategy":"validation","validationCode":"foreach (var route in router.GetRoutes())\n{\n    if (!moduleDef.HasHttpHandler(route.HandlerFunction))\n        throw new InvalidOperationException(\n            $\"Route '{route.Name}' references undefined handler '{route.HandlerFunction}'\");\n}\nModule.RegisterHttpRouter(router);","typeGuard":"static bool HasKnownHandler(ModuleDef def, string handler) =>\n    !string.IsNullOrWhiteSpace(handler) && def.HasHttpHandler(handler);","tryCatchPattern":"try\n{\n    Module.RegisterHttpRouter(router);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"unknown handler\"))\n{\n    logger.LogError(ex, \"HTTP router references a handler not defined in the module\");\n}","preventionTips":["Derive route HandlerFunction names from the same source of truth as the handler definitions","Add a startup/unit test that registers the full router and asserts no ArgumentException","Grep for handler renames in code review and update the route table in the same commit","Register all handlers before calling RegisterHttpRouter"],"tags":["csharp","spacetimedb","router","handler-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-09-06T02:33:02.036Z","contentChangedAt":"2026-09-06T02:33:02.036Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}