{"record":{"id":"82dfa91bedf24e5b","repo":"astrid-runtime/astrid","slug":"helper-returns-the-scoped-reply","errorCode":null,"errorMessage":"helper returns the scoped reply","messagePattern":"helper returns the scoped reply","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-gateway/src/routes/sessions_tests.rs","lineNumber":780,"sourceCode":"            message: msg,\n        });\n    });\n\n    let body = serde_json::json!({ \"title\": \"renamed\" });\n    let payload = build_update_payload(correlation_id, \"sess-1\", &body).unwrap();\n    let value = request_capsule(\n        &bus,\n        TOPIC_UPDATE_REQUEST,\n        &response_topic,\n        payload,\n        correlation_id,\n        &principal,\n        None,\n        &[test_provider_source_id()],\n        CAPSULE_TIMEOUT,\n    )\n    .await\n    .expect(\"helper returns the scoped reply\");\n\n    capsule.await.expect(\"stand-in capsule joins\");\n    let summary = parse_session_field(&value)\n        .unwrap()\n        .expect(\"present session\");\n    assert_eq!(summary.session_id, \"sess-1\");\n    assert_eq!(summary.title.as_deref(), Some(\"renamed\"));\n}\n\n/// A reply stamped for a different principal is ignored. This protects a\n/// same-topic reply from satisfying another caller's request.\n#[tokio::test]\nasync fn request_capsule_ignores_wrong_principal_reply() {\n    let bus = Arc::new(EventBus::new());\n    let principal = PrincipalId::new(\"alice\").expect(\"valid principal\");\n    let correlation_id = \"corr-want-principal\";\n    let response_topic = format!(\"{TOPIC_LIST_RESPONSE_PREFIX}.{correlation_id}\");\n","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/routes/sessions_tests.rs#L762-L798","documentation":"This panic comes from `.expect(\"helper returns the scoped reply\")` on the awaited result of the request-capsule helper in `request_capsule_round_trips_update_reply`. The helper waited `CAPSULE_TIMEOUT` for a reply on `TOPIC_UPDATE_RESPONSE_PREFIX.<correlation_id>` and returned Err — typically a timeout because no acceptable reply arrived on the scoped topic.","triggerScenarios":"The stand-in capsule never publishes the updated SUMMARY reply on the scoped response topic, publishes it with the wrong principal/source stamp so the helper filters it out, or the helper times out at CAPSULE_TIMEOUT before the reply lands.","commonSituations":"Reply published to the unscoped topic instead of the correlation-scoped one; response stamped with a different principal or source_id and rejected by the defensive checks; CAPSULE_TIMEOUT too short under CI load; topic prefix constants out of sync.","solutions":["Verify the stand-in capsule publishes to `response_topic` (TOPIC_UPDATE_RESPONSE_PREFIX + correlation id) with a matching principal and the capsule's kernel source id.","Increase CAPSULE_TIMEOUT or make it configurable for slow CI runners.","Log the helper's error variant to distinguish timeout from filter-rejection.","Ensure the request the capsule matched carried the same correlation_id the helper is listening for."],"exampleFix":"// before\nlet value = update_session(...).await.expect(\"helper returns the scoped reply\");\n// after\nlet value = update_session(...).await\n    .unwrap_or_else(|e| panic!(\"helper returns the scoped reply: {e:?}\"));","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let value = helper(...).await\n    .unwrap_or_else(|e| panic!(\"helper returns the scoped reply: {e:?}\"));","preventionTips":["Publish replies on the correlation-scoped topic with matching principal and source id","Use a generous CAPSULE_TIMEOUT in CI","Log the helper error variant to distinguish timeout from rejection"],"tags":["rust","tokio","test","timeout","event-bus"],"backgroundTag":"request-timeout","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}