{"record":{"id":"7bc658f111f70897","repo":"EpicGames/lore","slug":"handler-should-succeed-even-for-a-miss","errorCode":null,"errorMessage":"handler should succeed even for a miss","messagePattern":"handler should succeed even for a miss","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lore-server/src/quic/replication_store_service/server.rs","lineNumber":1057,"sourceCode":"            .run_request_handler(AttributeMap::default().into(), parse_output)\n            .await\n            .expect(\"handler failed\");\n        let parsed_response =\n            get_metadata::parse_response(collapse_bytes(&service_output)).expect(\"Failed to parse\");\n        assert_eq!(parsed_response.match_made, StoreMatch::MatchFull);\n\n        // Regular ImmutableGetMetadata should NOT find it (main store is empty)\n        let parse_output = service\n            .parse_request_bytes(\n                &CommandHeader::new(Command::ImmutableGetMetadata as QuicOpCode, 0, 0),\n                collapse_bytes_without_header(&request.to_quic_chunks()),\n            )\n            .expect(\"Failed to parse\");\n\n        let service_output = service\n            .run_request_handler(AttributeMap::default().into(), parse_output)\n            .await\n            .expect(\"handler should succeed even for a miss\");\n        let parsed_response =\n            get_metadata::parse_response(collapse_bytes(&service_output)).expect(\"Failed to parse\");\n        assert_eq!(parsed_response.match_made, StoreMatch::MatchNone);\n    }\n\n    /// Helper to create a second independent store for local-store routing tests\n    async fn create_two_stores() -> (\n        Arc<dyn ImmutableStore>,\n        Arc<dyn ImmutableStore>,\n        Arc<lore_revision::interface::ExecutionContext>,\n    ) {\n        let (main_store, _, execution) = test_store_create()\n            .await\n            .expect(\"Failed to create main store\");\n        let (local_store, _, _) = test_store_create()\n            .await\n            .expect(\"Failed to create local store\");\n        (main_store, local_store, execution)","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/EpicGames/lore/blob/074eb0b0d1194c997d7cf28b55519e3e197b3e23/lore-server/src/quic/replication_store_service/server.rs#L1039-L1075","documentation":"In the test immutable_local_get_metadata_routes_to_local_store, the replication store service's run_request_handler is expected to succeed even when the metadata lookup misses (returns MatchNone). The .expect fires when the handler itself returns an error rather than a well-formed miss response, meaning routing or store plumbing failed before a match decision could be made.","triggerScenarios":"The local store is not wired into the service's routing (request goes to main store and errors), the execution context (LORE_CONTEXT scope) is missing/mismatched so the local store lookup fails, or run_request_handler returns an internal error for ImmutableLocalGetMetadata opcode.","commonSituations":"Changing routing tables so local-opcodes hit the wrong store, tearing down the local store before the request runs, or new required request attributes not being supplied in the test harness.","solutions":["Verify the local store created by create_two_stores is registered with the service before run_request_handler","Ensure the ExecutionContext is scoped (LORE_CONTEXT.scope) for the handler call exactly as production code does","Check run_request_handler's error to see which store/route failed and fix the routing entry","Update the test request construction if AttributeMap requirements changed"],"exampleFix":"// before\nlet service_output = service.run_request_handler(AttributeMap::default().into(), parse_output).await.expect(\"handler should succeed even for a miss\");\n// after\n// ensure local store is routed first:\n// service.register_local_store(local_store.clone());\nlet service_output = service.run_request_handler(AttributeMap::default().into(), parse_output).await.expect(\"handler should succeed even for a miss\");","handlingStrategy":"validation","validationCode":"// before running the handler, assert routing is set up\nassert!(service.has_local_store_route(Command::ImmutableLocalGetMetadata), \"local store route missing\");","typeGuard":"fn is_well_formed_output(bytes: &[u8]) -> bool { !bytes.is_empty() } // pre-check before parse_response","tryCatchPattern":"match service.run_request_handler(attrs, parse_output).await {\n    Ok(out) => { /* expect miss path */ },\n    Err(e) => eprintln!(\"handler failed on miss; check local-store routing: {e:?}\"),\n}","preventionTips":["Always register the local store with the service before local-routing tests","Scope handler calls in LORE_CONTEXT with the execution context from create_two_stores","Keep request attribute maps in sync with handler requirements","Assert routing table state early in tests to fail with a clear message"],"tags":["rust","test","quic","routing","replication"],"backgroundTag":"unexpected-response-shape","analyzedSha":"074eb0b0d1194c997d7cf28b55519e3e197b3e23","analyzedAt":"2026-09-13T09:00:57.509Z","contentChangedAt":"2026-09-13T09:00:57.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}