{"record":{"id":"e063ed71374b2d7b","repo":"zed-industries/zed","slug":"invalid-role-value","errorCode":null,"errorMessage":"invalid role '{value}'","messagePattern":"invalid role '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/open_router/src/open_router.rs","lineNumber":60,"sourceCode":"#[derive(Clone, Copy, Serialize, Deserialize, Debug, Eq, PartialEq)]\n#[serde(rename_all = \"lowercase\")]\npub enum Role {\n    User,\n    Assistant,\n    System,\n    Tool,\n}\n\nimpl TryFrom<String> for Role {\n    type Error = anyhow::Error;\n\n    fn try_from(value: String) -> Result<Self> {\n        match value.as_str() {\n            \"user\" => Ok(Self::User),\n            \"assistant\" => Ok(Self::Assistant),\n            \"system\" => Ok(Self::System),\n            \"tool\" => Ok(Self::Tool),\n            _ => Err(anyhow!(\"invalid role '{value}'\")),\n        }\n    }\n}\n\nimpl From<Role> for String {\n    fn from(val: Role) -> Self {\n        match val {\n            Role::User => \"user\".to_owned(),\n            Role::Assistant => \"assistant\".to_owned(),\n            Role::System => \"system\".to_owned(),\n            Role::Tool => \"tool\".to_owned(),\n        }\n    }\n}\n\n#[cfg_attr(feature = \"schemars\", derive(schemars::JsonSchema))]\n#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]\npub struct Model {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/open_router/src/open_router.rs#L42-L78","documentation":"Conversion guard in Role::try_from: a role string outside the closed set user/assistant/system/tool (e.g. from a deserialized payload or API response) cannot be mapped to the Role enum, so parsing fails naming the offending value.","triggerScenarios":"Thrown at crates/open_router/src/open_router.rs:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the source payload for a misspelled or unexpected role value","Update the OpenRouter schema handling if the API introduced a new role","Sanitize/normalize role strings before conversion"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}