{"record":{"id":"84490a47c85c8755","repo":"astrid-runtime/astrid","slug":"alice","errorCode":null,"errorMessage":"alice","messagePattern":"alice","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-gateway/src/routes/sessions_tests.rs","lineNumber":720,"sourceCode":"    assert!(parse_search_response(body).unwrap().next_cursor.is_none());\n}\n\n#[test]\nfn parse_search_response_rejects_garbage() {\n    let body = serde_json::json!({ \"results\": \"not-an-array\" });\n    assert!(matches!(\n        parse_search_response(body).unwrap_err(),\n        GatewayError::Kernel(_)\n    ));\n}\n\n/// Live round-trip over a real `EventBus` for the `update` verb: the\n/// stand-in capsule receives the principal-stamped, present-keys-only\n/// patch and replies with an updated SUMMARY on the scoped topic.\n#[tokio::test]\nasync fn request_capsule_round_trips_update_reply() {\n    let bus = Arc::new(EventBus::new());\n    let principal = PrincipalId::new(\"alice\").expect(\"valid principal\");\n    let correlation_id = \"corr-upd-1\";\n    let response_topic = format!(\"{TOPIC_UPDATE_RESPONSE_PREFIX}.{correlation_id}\");\n\n    let mut req_rx = bus.subscribe_topic(TOPIC_UPDATE_REQUEST.to_string());\n    let bus_capsule = Arc::clone(&bus);\n    let resp_topic = response_topic.clone();\n    let cid = correlation_id.to_string();\n    let capsule = tokio::spawn(async move {\n        let event = req_rx.recv().await.expect(\"request arrives\");\n        let AstridEvent::Ipc { message, .. } = &*event else {\n            panic!(\"expected IPC request\");\n        };\n        // Principal-stamped, and the patch carries only the sent key.\n        assert_eq!(message.principal.as_deref(), Some(\"alice\"));\n        assert_ne!(message.source_id, Uuid::nil());\n        assert_eq!(message.origin, MessageOrigin::RemoteGateway);\n        if let IpcPayload::RawJson(v) = &message.payload {\n            assert_eq!(v[\"title\"], \"renamed\");","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/routes/sessions_tests.rs#L702-L738","documentation":"This panic comes from `PrincipalId::new(\"alice\").expect(\"valid principal\")` in `request_capsule_round_trips_update_reply`. `PrincipalId::new` validates its input and returns a Result; the expect fires when the principal string fails validation, so no valid PrincipalId could be constructed for the test run.","triggerScenarios":"Calling `PrincipalId::new` with a string that violates the identifier rules (empty, too long, or containing characters outside the allowed set). In this test that means the hard-coded `\"alice\"` was rejected, which only happens if the validation rules were tightened or the constructor signature/behavior changed.","commonSituations":"A validation change made short lowercase names invalid; the constructor was refactored to require a prefixed/UUID form; copy-pasted principal constants contain whitespace or non-ASCII characters.","solutions":["Print or log the error from PrincipalId::new instead of expect() to see the exact validation rule that rejected \"alice\".","Update the fixture principal to a value that satisfies the current PrincipalId validation rules.","If \"alice\" should remain valid, relax or fix the validation in PrincipalId::new.","Replace expect with a test-level assert that surfaces the underlying error message."],"exampleFix":"// before\nlet principal = PrincipalId::new(\"alice\").expect(\"valid principal\");\n// after\nlet principal = PrincipalId::new(\"alice\")\n    .unwrap_or_else(|e| panic!(\"valid principal: {e:?}\"));","handlingStrategy":"validation","validationCode":"if name.is_empty() || name.len() > 64 || !name.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_') {\n    return Err(\"invalid principal id\");\n}","typeGuard":"fn valid_principal(s: &str) -> Option<PrincipalId> {\n    PrincipalId::new(s).ok()\n}","tryCatchPattern":"let principal = PrincipalId::new(\"alice\")\n    .unwrap_or_else(|e| panic!(\"valid principal: {e:?}\"));","preventionTips":["Centralize principal fixtures in one module validated by a unit test","Surface constructor errors instead of bare expect","Add a test asserting known fixture principals pass validation"],"tags":["rust","test","panic","validation"],"backgroundTag":"invalid-identifier-format","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"}