{"record":{"id":"d3a10ee03c9a879e","repo":"quickwit-oss/quickwit","slug":"lambda-function-is-in-failed-state","errorCode":null,"errorMessage":"lambda function '{}' is in Failed state: {}","messagePattern":"lambda function '(.+?)' is in Failed state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-lambda-client/src/deploy.rs","lineNumber":467,"sourceCode":"\n    for attempt in 0..MAX_WAIT_ATTEMPTS {\n        interval.tick().await;\n\n        let response = client\n            .get_function()\n            .function_name(function_name)\n            .send()\n            .await\n            .context(\"failed to get function status\")?;\n\n        let Some(config) = response.configuration() else {\n            continue;\n        };\n\n        // Check for terminal failure states.\n        if config.state() == Some(&State::Failed) {\n            let reason = config.state_reason().unwrap_or(\"unknown reason\");\n            anyhow::bail!(\n                \"lambda function '{}' is in Failed state: {}\",\n                function_name,\n                reason\n            );\n        }\n\n        let last_update_status: &LastUpdateStatus = config\n            .last_update_status()\n            .unwrap_or(&LastUpdateStatus::Successful);\n\n        if last_update_status == &LastUpdateStatus::Failed {\n            let reason = config\n                .last_update_status_reason()\n                .unwrap_or(\"unknown reason\");\n            anyhow::bail!(\n                \"lambda function '{}' last update failed: {}\",\n                function_name,\n                reason","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-lambda-client/src/deploy.rs#L449-L485","documentation":"wait_for_function_ready polls the Lambda function configuration until the function is Active. If the poll observes State == Failed, it bails with the function name and AWS-provided state reason, since a Failed Lambda state is terminal and will never become ready.","triggerScenarios":"Polling during update_function_code (or directly) when GetFunctionConfiguration returns State=Failed with a state_reason (e.g., failed deployment, image pull error, invalid package/permissions).","commonSituations":"Bad Lambda deployment package or container image; insufficient Lambda execution role permissions; VPC/network misconfiguration causing the function create/update to fail; stale artifact URL/SHA in the lambda client build script.","solutions":["Read the state_reason in the error message and fix the underlying deployment issue (package, image, role, or VPC config).","Retry the update with a valid function code/artifact (check the artifact URL and SHA256 configured in build.rs).","Delete and recreate the function if it is stuck in Failed state after repeated update attempts."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match wait_for_function_ready(&lambda, \"my-function\", timeout).await {\n    Ok(_) => { /* function active */ }\n    Err(e) if e.to_string().contains(\"is in Failed state\") => {\n        // terminal failure: read the reason, fix deployment inputs, do not keep polling\n    }\n    Err(e) => { /* transient: may retry within timeout */ }\n}","preventionTips":["Validate the deployment package/container image and IAM role before updating.","Monitor Lambda State/StateReason after updates instead of waiting for readiness blindly.","Keep the artifact URL and SHA256 in build.rs current and reachable."],"tags":["aws-lambda","deployment","function-state","rust"],"backgroundTag":"api-error-response","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}