{"record":{"id":"cba4bbc3b72db497","repo":"nikivdev/code","slug":"failed-to-store-token-in-keychain","errorCode":null,"errorMessage":"failed to store token in Keychain","messagePattern":"failed to store token in Keychain","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/env.rs","lineNumber":288,"sourceCode":"}\n\nfn set_keychain_token(api_url: &str, token: &str) -> Result<()> {\n    let service = keychain_service(api_url);\n    let status = Command::new(\"security\")\n        .args([\n            \"add-generic-password\",\n            \"-a\",\n            \"flow\",\n            \"-s\",\n            &service,\n            \"-w\",\n            token,\n            \"-U\",\n        ])\n        .status()\n        .context(\"failed to store token in Keychain\")?;\n    if !status.success() {\n        bail!(\"failed to store token in Keychain\");\n    }\n    Ok(())\n}\n\nfn set_keychain_ai_token(api_url: &str, token: &str) -> Result<()> {\n    let service = keychain_service_ai(api_url);\n    let status = Command::new(\"security\")\n        .args([\n            \"add-generic-password\",\n            \"-a\",\n            \"flow\",\n            \"-s\",\n            &service,\n            \"-w\",\n            token,\n            \"-U\",\n        ])\n        .status()","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/env.rs#L270-L306","documentation":"Error \"failed to store token in Keychain\" thrown in nikivdev/code.","triggerScenarios":"Thrown at src/env.rs:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}