{"record":{"id":"bcba05ebde532c6f","repo":"astrid-runtime/astrid","slug":"principal-id","errorCode":null,"errorMessage":"principal id","messagePattern":"principal id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/audit_retirement_tests.rs","lineNumber":70,"sourceCode":"    require_audit_integrity(&valid).expect(\"valid history is accepted by the derived helper\");\n\n    let invalid = vec![(\n        SessionId::new(),\n        ChainVerificationResult {\n            valid: false,\n            entries_verified: 1,\n            issues: Vec::new(),\n        },\n    )];\n    assert!(require_audit_integrity(&invalid).is_err());\n}\n\n#[test]\nfn audit_boot_rejects_unhandled_non_default_source() {\n    let directory = tempfile::tempdir().expect(\"temporary home\");\n    let home = AstridHome::from_path(directory.path().join(\".astrid\"));\n    home.ensure().expect(\"home layout\");\n    let other = astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\");\n    let other_home = home.principal_home(&other);\n    other_home.ensure().expect(\"legacy principal layout\");\n    std::fs::write(other_home.audit_dir().join(\"entry\"), b\"audit\").expect(\"non-empty audit\");\n    let default_source = home\n        .principal_home(&astrid_core::PrincipalId::default())\n        .audit_dir();\n\n    let error = preflight_legacy_audit_sources(&home, &default_source)\n        .expect_err(\"unhandled non-empty source must block boot\");\n    assert!(\n        error\n            .to_string()\n            .contains(\"only the default principal source\")\n    );\n    assert!(other_home.audit_dir().exists());\n    assert_eq!(\n        std::fs::read(other_home.audit_dir().join(\"entry\")).expect(\"preserved\"),\n        b\"audit\"","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/audit_retirement_tests.rs#L52-L88","documentation":"Panic from `astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\")`. `PrincipalId::new` validates the supplied string and returns Err for identifiers that violate the principal-id rules (e.g. empty, illegal characters, or overly long). The expect message means the string was not accepted as a valid principal id.","triggerScenarios":"Calling `PrincipalId::new` with a string that fails validation — empty string, whitespace, invalid characters, or a value exceeding the length limit. In this test the literal \"other\" is expected valid; a failure indicates the validator changed or the input deviates.","commonSituations":"Version drift where `PrincipalId::new` gained stricter validation after the test was written; copying the constructor pattern with user-controlled strings; passing an empty or formatted (non-plain) string.","solutions":["Log/inspect the Err value from PrincipalId::new to see which validation rule the string violates.","Ensure the input matches the accepted charset/format documented for PrincipalId (plain, non-empty, allowed characters).","Update the test or caller to use a conforming identifier string.","If validation changed intentionally, update PrincipalId::new call sites and fixtures to the new format."],"exampleFix":"// before\nlet other = astrid_core::PrincipalId::new(\"other\".to_owned()).expect(\"principal id\");\n// after\nlet other = astrid_core::PrincipalId::new(\"other\".to_owned())\n    .unwrap_or_else(|e| panic!(\"principal id rejected: {e}\"));","handlingStrategy":"validation","validationCode":"fn is_valid_principal_id(s: &str) -> bool {\n    !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n}","typeGuard":null,"tryCatchPattern":"let other = astrid_core::PrincipalId::new(input.to_owned())\n    .map_err(|e| format!(\"invalid principal id: {e}\"))?;","preventionTips":["Validate identifier strings against the documented charset before calling PrincipalId::new.","Never pass empty or user-formatted strings to PrincipalId::new.","Re-check fixtures after upgrading astrid-core in case validation tightened."],"tags":["validation","identifier","test","panic"],"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"}