{"record":{"id":"bab6f7b9d8e03839","repo":"sigoden/aichat","slug":"invalid-application-default-credentials-json","errorCode":null,"errorMessage":"Invalid application_default_credentials.json","messagePattern":"Invalid application_default_credentials\\.json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/vertexai.rs","lineNumber":511,"sourceCode":"        .as_ref()\n        .map(PathBuf::from)\n        .or_else(default_adc_file)\n        .ok_or_else(|| anyhow!(\"No application_default_credentials.json\"))?;\n    let data = tokio::fs::read_to_string(adc_file).await?;\n    let data: Value = serde_json::from_str(&data)?;\n    if let (Some(client_id), Some(client_secret), Some(refresh_token)) = (\n        data[\"client_id\"].as_str(),\n        data[\"client_secret\"].as_str(),\n        data[\"refresh_token\"].as_str(),\n    ) {\n        Ok(json!({\n            \"client_id\": client_id,\n            \"client_secret\": client_secret,\n            \"refresh_token\": refresh_token,\n            \"grant_type\": \"refresh_token\",\n        }))\n    } else {\n        bail!(\"Invalid application_default_credentials.json\")\n    }\n}\n\n#[cfg(not(windows))]\nfn default_adc_file() -> Option<PathBuf> {\n    let mut path = dirs::home_dir()?;\n    path.push(\".config\");\n    path.push(\"gcloud\");\n    path.push(\"application_default_credentials.json\");\n    Some(path)\n}\n\n#[cfg(windows)]\nfn default_adc_file() -> Option<PathBuf> {\n    let mut path = dirs::config_dir()?;\n    path.push(\"gcloud\");\n    path.push(\"application_default_credentials.json\");\n    Some(path)","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/vertexai.rs#L493-L529","documentation":"Validation failure when parsing Google application_default_credentials.json: the file exists and was read successfully, but its JSON lacks required fields (client_id, client_secret, refresh_token) or they are not strings — i.e. the file is present but not a valid ADC file (wrong file, corrupted, or a placeholder).","triggerScenarios":"Thrown at src/client/vertexai.rs:511 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate credentials with 'gcloud auth application-default login' so the file contains client_id, client_secret, and refresh_token","Verify the file at ~/.config/gcloud/application_default_credentials.json is not corrupted or a service-account key (which has a different shape)","If ADC is not available, switch the Vertex AI auth method to an API-key-based setup or export proper service account credentials"],"exampleFix":null,"handlingStrategy":"validation","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"}