{"record":{"id":"b6c4d85b7db56b22","repo":"sigoden/aichat","slug":"no-role","errorCode":null,"errorMessage":"No role","messagePattern":"No role","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/mod.rs","lineNumber":903,"sourceCode":"            session.set_role(role);\n        } else {\n            self.role = Some(role);\n        }\n        Ok(())\n    }\n\n    pub fn role_info(&self) -> Result<String> {\n        if let Some(session) = &self.session {\n            if session.role_name().is_some() {\n                let role = session.to_role();\n                Ok(role.export())\n            } else {\n                bail!(\"No session role\")\n            }\n        } else if let Some(role) = &self.role {\n            Ok(role.export())\n        } else {\n            bail!(\"No role\")\n        }\n    }\n\n    pub fn exit_role(&mut self) -> Result<()> {\n        if let Some(session) = self.session.as_mut() {\n            session.guard_empty()?;\n            session.clear_role();\n        } else if self.role.is_some() {\n            self.role = None;\n        }\n        Ok(())\n    }\n\n    pub fn retrieve_role(&self, name: &str) -> Result<Role> {\n        let names = Self::list_roles(false);\n        let mut role = if names.contains(&name.to_string()) {\n            let path = Self::role_file(name);\n            let content = read_to_string(&path)?;","sourceCodeStart":885,"sourceCodeEnd":921,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/config/mod.rs#L885-L921","documentation":"Sentinel guard in role_info(): when there is no active session and self.role is also None, no role configuration exists to export, so the function bails. It is a None-check on the optional role field; the state at fault is a fresh configuration with no role selected.","triggerScenarios":"Thrown at src/config/mod.rs:903 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a role with .role <name> before requesting role info","Create a role first if none exists","Inspect the model configuration directly instead of role-specific info"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}