{"record":{"id":"c6dea4b526afe55b","repo":"BoundaryML/baml","slug":"request-options","errorCode":null,"errorMessage":"{} {}\n\nRequest options: {}","messagePattern":"(.+?) (.+?)\n\nRequest options: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":1072,"sourceCode":"                    None,\n                    env_vars.clone(),\n                )\n                .await;\n            let res = response_res?;\n            let (_, llm_resp, val) = res\n                .event_chain()\n                .iter()\n                .last()\n                .context(\"Expected non-empty event chain\")?;\n            if let Some(expr_tx) = expr_tx {\n                expr_tx.unbounded_send(vec![]).unwrap();\n            }\n            let complete_resp = match llm_resp {\n                LLMResponse::Success(complete_llm_response) => Ok(complete_llm_response),\n                LLMResponse::InternalFailure(e) => Err(anyhow::anyhow!(\"{}\", e)),\n                LLMResponse::UserFailure(e) => Err(anyhow::anyhow!(\"{}\", e)),\n                LLMResponse::Cancelled(e) => Err(anyhow::anyhow!(\"Cancelled: {}\", e)),\n                LLMResponse::LLMFailure(e) => Err(anyhow::anyhow!({\n                    let scrubbed_opts =\n                        crate::redaction::scrub_baml_options(&e.request_options, &env_vars, false);\n                    format!(\n                        \"{} {}\\n\\nRequest options: {}\",\n                        e.code,\n                        e.message,\n                        serde_json::to_string(&scrubbed_opts).unwrap_or_default()\n                    )\n                })),\n            }?;\n            let test_constraints_result = if constraints.is_empty() {\n                TestConstraintsResult::empty()\n            } else {\n                match val {\n                    Some(Ok(value)) => {\n                        let value_with_constraints = value.0.map_meta(|m| m.1.clone());\n                        evaluate_test_constraints(\n                            &params,","sourceCodeStart":1054,"sourceCodeEnd":1090,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L1054-L1090","documentation":"For LLMResponse::LLMFailure(e), run_test_with_expr_events formats an error as '{code} {message}\\n\\nRequest options: {json}' where the request options are first passed through scrub_baml_options to redact secrets (api keys, headers) using the provided env vars. This surfaces the provider's HTTP error code and message plus a sanitized dump of the request options that caused it.","triggerScenarios":"Running an expr-function test when the provider returns an HTTP error response that BAML maps to LLMResponse::LLMFailure; the formatted code/message/request options are raised as an anyhow error.","commonSituations":"401/403 from bad API keys; 404 from a wrong model name; 429 rate limiting; 5xx provider outages; invalid request body rejected by the provider.","solutions":["Read the code and message: fix auth (401/403), model name (404), rate limits (429, add backoff), or request shape accordingly","Inspect the redacted 'Request options' section to see exactly what was sent","Verify env vars for keys/headers are set so the request is built correctly","Check provider status pages if code is 5xx and retry later"],"exampleFix":"// before\n{\"model\": \"gpt-99-nonexistent\", ...} // 404 LLMFailure\n// after\n{\"model\": \"gpt-4o\", ...}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Parse the 'code message' prefix to branch on HTTP status\nlet err = match run_test_with_expr_events(...).await {\n    Err(e) => e,\n    Ok(r) => return Ok(r),\n};\nif let Some(code) = parse_http_code(&err.to_string()) {\n    match code {\n        429 => schedule_backoff_and_retry(),\n        401 | 403 => eprintln!(\"fix credentials\"),\n        _ => eprintln!(\"provider error {code}: {err}\"),\n    }\n}","preventionTips":["Monitor for 429s and add rate limiting/backoff to test suites","Rotate and validate API keys regularly","Read the redacted request options dump to catch malformed requests early"],"tags":["llm","http-error","api-error-response","test-runner"],"backgroundTag":"http-error-response","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}