{"record":{"id":"7c7638629199014e","repo":"quickwit-oss/quickwit","slug":"update-function-code-response-missing-code-sha256","errorCode":null,"errorMessage":"update_function_code response missing code_sha256","messagePattern":"update_function_code response missing code_sha256","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-lambda-client/src/deploy.rs","lineNumber":382,"sourceCode":"    function_name: &str,\n) -> anyhow::Result<String> {\n    info!(\n        function_name = %function_name,\n        \"updating Lambda function code to current binary\"\n    );\n\n    let response = client\n        .update_function_code()\n        .function_name(function_name)\n        .zip_file(Blob::new(LAMBDA_BINARY))\n        .architectures(Architecture::Arm64)\n        .send()\n        .await\n        .context(\"failed to update Lambda function code\")?;\n\n    let code_sha256 = response\n        .code_sha256()\n        .ok_or_else(|| anyhow!(\"update_function_code response missing code_sha256\"))?\n        .to_string();\n\n    wait_for_function_ready(client, function_name).await?;\n\n    Ok(code_sha256)\n}\n\n/// Publish a new immutable version from `$LATEST` with our description.\n///\n/// The `code_sha256` parameter guards against races: if another process\n/// overwrote `$LATEST` since our `update_function_code` call, AWS will\n/// reject the publish.\n///\n/// Returns the version number (e.g., \"8\").\nasync fn publish_version(\n    client: &LambdaClient,\n    function_name: &str,\n    code_sha256: &str,","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-lambda-client/src/deploy.rs#L364-L400","documentation":"After calling UpdateFunctionCode, the SDK response's code_sha256 field is expected to be present; AWS documents it as always returned, so Quickwit treats a None as a violation of the API contract and errors out. This guards callers who rely on the returned hash for verifying the deployed code version.","triggerScenarios":"Calling deploy_lambda_function on an existing function: the UpdateFunctionCode response arrives without code_sha256 — effectively only possible with an unexpected/changed AWS SDK response or a mocked/partial response.","commonSituations":"AWS API behavior change or SDK upgrade where the field moved/renamed; testing against a stubbed LocalStack/moto that omits code_sha256 in the response.","solutions":["If running against an emulator (LocalStack/moto), upgrade it so UpdateFunctionCode returns code_sha256.","Check the aws-sdk-lambda version matches what quickwit-lambda-client expects; upgrade the SDK.","As a last resort, fetch the hash via GetFunction/GetFunctionConfiguration after the update instead of relying on the update response."],"exampleFix":"// before\nlet code_sha256 = response.code_sha256().ok_or_else(|| anyhow!(\"update_function_code response missing code_sha256\"))?.to_string();\n// after: fall back to fetching the configuration\nlet code_sha256 = match response.code_sha256() {\n    Some(hash) => hash.to_string(),\n    None => client.get_function_configuration().function_name(function_name).send().await?.code_sha256().context(\"missing code_sha256\")?.to_string(),\n};","handlingStrategy":"fallback","validationCode":null,"typeGuard":"fn has_code_sha256(resp: &UpdateFunctionCodeOutput) -> bool { resp.code_sha256().is_some() }","tryCatchPattern":"let sha = deploy_lambda_function(...).await?;\n// if this errors, fall back to get_function_configuration to obtain code_sha256","preventionTips":["Test deployments against an up-to-date LocalStack/moto that returns code_sha256.","Keep aws-sdk-lambda versions consistent between client code and lockfile.","Don't cache assumptions about AWS response fields across SDK upgrades."],"tags":["aws","lambda","api-contract","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}