{"record":{"id":"c2a8b647716e001b","repo":"zed-industries/zed","slug":"model-must-be-specified","errorCode":null,"errorMessage":"Model must be specified","messagePattern":"Model must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/google_ai/src/google_ai.rs","lineNumber":81,"sourceCode":"                    }\n                    Err(error) => Some(Err(anyhow!(error))),\n                }\n            })\n            .boxed())\n    } else {\n        let mut text = String::new();\n        response.body_mut().read_to_string(&mut text).await?;\n        Err(anyhow!(\n            \"error during streamGenerateContent, status code: {:?}, body: {}\",\n            response.status(),\n            text\n        ))\n    }\n}\n\npub fn validate_generate_content_request(request: &GenerateContentRequest) -> Result<()> {\n    if request.model.is_empty() {\n        bail!(\"Model must be specified\");\n    }\n\n    if request.contents.is_empty() {\n        bail!(\"Request must contain at least one content item\");\n    }\n\n    if let Some(user_content) = request\n        .contents\n        .iter()\n        .find(|content| content.role == Role::User)\n        && user_content.parts.is_empty()\n    {\n        bail!(\"User content must contain at least one part\");\n    }\n\n    Ok(())\n}\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/google_ai/src/google_ai.rs#L63-L99","documentation":"validate_generate_content_request rejects a GenerateContentRequest whose 'model' field is an empty string. The Generative Language API needs a model id (e.g. gemini-2.0-flash) to route the request; an empty model means the caller built the struct without ever populating it. This is a client-side validation error, raised before any network I/O.","triggerScenarios":"Constructing GenerateContentRequest with the default empty model string and passing it to generate/stream; copying or templating a request and dropping the model field; loading the model id from an unset setting or environment variable.","commonSituations":"New integration code that forgets the model id; model selection wired to an unset config key; refactors that move the model into a different field and leave the struct default.","solutions":["Set request.model to a valid model id before sending","Populate the model from configuration and assert non-empty at startup so the misconfiguration surfaces immediately","Centralize request construction in one builder or function that requires the model as an argument"],"exampleFix":"// before\nlet request = GenerateContentRequest { model: String::new(), contents, ..Default::default() };\n\n// after\nlet request = GenerateContentRequest { model: \"gemini-2.0-flash\".into(), contents, ..Default::default() };","handlingStrategy":"validation","validationCode":"// before calling the API\nanyhow::ensure!(!request.model.trim().is_empty(), \"model id is required\");","typeGuard":"fn has_model(request: &GenerateContentRequest) -> bool {\n    !request.model.trim().is_empty()\n}","tryCatchPattern":null,"preventionTips":["Make the model a required constructor argument instead of a settable defaulted field","Validate the request once in a shared send wrapper","Fail fast at startup if the model comes from configuration"],"tags":["google-ai","request-validation","llm-provider"],"backgroundTag":"missing-model-parameter","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"}