{"record":{"id":"1ca360fa06cb83b3","repo":"warpdotdev/warp","slug":"field-is-required","errorCode":null,"errorMessage":"Field '{}' is required","messagePattern":"Field '(.+?)' is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/auth_secret_types.rs","lineNumber":57,"sourceCode":"const CODEX_LEARN_MORE_URL: &str =\n    \"https://docs.warp.dev/platform/harnesses/authentication/#connecting-codex-credentials\";\nconst CLAUDE_LEARN_MORE_URL: &str =\n    \"https://docs.warp.dev/platform/harnesses/authentication/#connecting-claude-code-credentials\";\n\npub fn build_managed_secret_value(\n    info: &AuthSecretTypeInfo,\n    field_values: &[String],\n) -> Result<ManagedSecretValue> {\n    if field_values.len() != info.fields.len() {\n        return Err(anyhow!(\n            \"Expected {} field values, got {}\",\n            info.fields.len(),\n            field_values.len()\n        ));\n    }\n    for (field, value) in info.fields.iter().zip(field_values.iter()) {\n        if !field.optional && value.trim().is_empty() {\n            return Err(anyhow!(\"Field '{}' is required\", field.label));\n        }\n    }\n    match info.secret_type {\n        ManagedSecretType::AnthropicApiKey => Ok(ManagedSecretValue::anthropic_api_key(\n            field_values[0].clone(),\n        )),\n        ManagedSecretType::AnthropicBedrockApiKey => {\n            Ok(ManagedSecretValue::anthropic_bedrock_api_key(\n                field_values[0].clone(),\n                field_values[1].clone(),\n            ))\n        }\n        ManagedSecretType::AnthropicBedrockAccessKey => {\n            let session_token = if field_values[2].trim().is_empty() {\n                None\n            } else {\n                Some(field_values[2].clone())\n            };","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/auth_secret_types.rs#L39-L75","documentation":"Inside build_managed_secret_value, after the count check, each zipped (field, value) pair is validated: any field with optional == false whose value trims to empty fails with this message naming the field's label.","triggerScenarios":"Submitting the harness FTUX credential form with a required field left blank or containing only whitespace (auth_secret_types.rs:56-59).","commonSituations":"User pastes spaces into the API key box; form trims but does not block submission; browser autofill leaves the field empty; automated caller passes placeholder empty strings for convenience.","solutions":["Client-side: trim inputs and disable submit until every non-optional field is non-empty","Show the exact field label from info.fields so the user knows which input to fix","In automated callers, assert !value.trim().is_empty() for required fields before building"],"exampleFix":"// before\nlet value = build_managed_secret_value(&info, &field_values)?;\n\n// after\nlet missing: Vec<&str> = info.fields.iter().zip(field_values.iter())\n    .filter(|(f, v)| !f.optional && v.trim().is_empty())\n    .map(|(f, _)| f.label)\n    .collect();\nif !missing.is_empty() {\n    return Err(anyhow!(\"Missing required fields: {}\", missing.join(\", \")));\n}\nlet value = build_managed_secret_value(&info, &field_values)?;","handlingStrategy":"validation","validationCode":"let missing: Vec<&str> = info.fields.iter().zip(field_values.iter())\n    .filter(|(f, v)| !f.optional && v.trim().is_empty())\n    .map(|(f, _)| f.label)\n    .collect();\nassert!(missing.is_empty(), \"required fields empty: {missing:?}\");","typeGuard":"fn required_fields_satisfied(info: &AuthSecretTypeInfo, values: &[String]) -> bool {\n    info.fields.iter().zip(values.iter())\n        .all(|(f, v)| f.optional || !v.trim().is_empty())\n}","tryCatchPattern":null,"preventionTips":["Trim user input at the form layer and block submit on empty required fields","Highlight the exact field label from info.fields in validation messages","Never substitute placeholder strings for required secrets"],"tags":["rust","warp","validation","auth","forms"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}