{"record":{"id":"96a7aa51cfecaf8e","repo":"clockworklabs/SpacetimeDB","slug":"no-such-view","errorCode":"NO_SUCH_VIEW","errorMessage":"ERROR: Invalid view ID %u (have %zu views)\\n","messagePattern":"ERROR: Invalid view ID %u \\(have %zu views\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bindings-cpp/src/internal/Module.cpp","lineNumber":527,"sourceCode":"    if (SpacetimeDB::Internal::has_reducer_error()) {\n        std::string error_msg = SpacetimeDB::Internal::get_reducer_error();\n        WriteBytes(error_sink, std::vector<uint8_t>(error_msg.begin(), error_msg.end()));\n        return StatusCode::HOST_CALL_FAILURE;\n    }\n\n    return StatusCode::OK;\n}\n\n// Dispatch function for views with ViewContext (has sender)\nint16_t Module::__call_view__(\n    uint32_t id,\n    uint64_t sender_0, uint64_t sender_1, uint64_t sender_2, uint64_t sender_3,\n    BytesSource args_source,\n    BytesSink result_sink\n) {\n    // Check if view ID is valid\n    if (id >= g_view_handlers.size()) {\n        fprintf(stderr, \"ERROR: Invalid view ID %u (have %zu views)\\n\", \n                id, g_view_handlers.size());\n        return -1;  // NO_SUCH_VIEW\n    }\n    \n    // Create sender identity from the 4 uint64_t parts\n    std::array<uint8_t, 32> sender_bytes{};\n    std::memcpy(sender_bytes.data(), &sender_0, 8);\n    std::memcpy(sender_bytes.data() + 8, &sender_1, 8);\n    std::memcpy(sender_bytes.data() + 16, &sender_2, 8);\n    std::memcpy(sender_bytes.data() + 24, &sender_3, 8);\n    \n    Identity sender_identity(sender_bytes);\n    \n    // Create view context\n    ViewContext ctx(sender_identity);\n    \n    // Get the handler\n    const auto& handler_info = g_view_handlers[id];","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-cpp/src/internal/Module.cpp#L509-L545","documentation":"Dispatch guard in Module::__call_view__: the host called a view by numeric ID >= g_view_handlers.size(). The function logs the message and returns -1 (NO_SUCH_VIEW), failing the view call. As with the reducer case, the server's view table from publish time disagrees with the handlers actually registered in the running binary.","triggerScenarios":"Stale module binary vs. server metadata (views added/removed without a clean republish); view registration macros conditionally compiled out; partial module init that skipped some __preinit__ view registrations.","commonSituations":"Adding or renaming views between module versions while old server-side metadata or cached bindings are in use; build-configuration differences stripping view macros.","solutions":["Republish the module so the published view list matches the binary, then retry","Keep view registration macros unconditional so the handler list is deterministic across builds","Inspect server logs for module init errors that may have cut registration short","Regenerate client bindings after any view schema change"],"exampleFix":"// before\n#ifdef ENABLE_VIEWS\nVIEW(list_items) { /* ... */ }\n#endif\n\n// after\nVIEW(list_items) { /* ... */ } // registered in every build","handlingStrategy":"validation","validationCode":"// post-build test: assert view handler counts are stable\n// assert(Module::GetViewHandlerCount() == EXPECTED_VIEWS);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register views unconditionally in every build configuration","Republish after any view changes and regenerate bindings","Watch for partial init failures in server logs that shrink the handler table"],"tags":["spacetimedb","cpp","view","dispatch","module-version-mismatch"],"backgroundTag":"no-such-view","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}