sigoden/aichat · error
No role
Error message
No role
What it means
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.
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
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at src/config/mod.rs:903 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/b6c4d85b7db56b22.
Report an issue: GitHub.
Appendix: source
Thrown at src/config/mod.rs:903
session.set_role(role);
} else {
self.role = Some(role);
}
Ok(())
}
pub fn role_info(&self) -> Result<String> {
if let Some(session) = &self.session {
if session.role_name().is_some() {
let role = session.to_role();
Ok(role.export())
} else {
bail!("No session role")
}
} else if let Some(role) = &self.role {
Ok(role.export())
} else {
bail!("No role")
}
}
pub fn exit_role(&mut self) -> Result<()> {
if let Some(session) = self.session.as_mut() {
session.guard_empty()?;
session.clear_role();
} else if self.role.is_some() {
self.role = None;
}
Ok(())
}
pub fn retrieve_role(&self, name: &str) -> Result<Role> {
let names = Self::list_roles(false);
let mut role = if names.contains(&name.to_string()) {
let path = Self::role_file(name);
let content = read_to_string(&path)?;View on GitHub (pinned to 82976d349a)