{"record":{"id":"6a04aab923362719","repo":"anomalyco/sst","slug":"failed-to-update-function-s-s","errorCode":null,"errorMessage":"failed to update function %s: %s","messagePattern":"failed to update function (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/server/resource/aws-function-code-updater.go","lineNumber":130,"sourceCode":"\n\tfor {\n\t\tret, err := client.GetFunction(r.context, &lambda.GetFunctionInput{\n\t\t\tFunctionName: aws.String(input.FunctionName),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif ret.Configuration.LastUpdateStatus == types.LastUpdateStatusSuccessful {\n\t\t\treturn nil\n\t\t}\n\n\t\tif ret.Configuration.LastUpdateStatus == types.LastUpdateStatusFailed {\n\t\t\treason := \"Unknown\"\n\t\t\tif ret.Configuration.LastUpdateStatusReason != nil {\n\t\t\t\treason = *ret.Configuration.LastUpdateStatusReason\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to update function %s: %s\", ret.Configuration.LastUpdateStatusReasonCode, reason)\n\t\t}\n\n\t\ttime.Sleep(300 * time.Millisecond)\n\t}\n}\n\n","sourceCodeStart":112,"sourceCodeEnd":137,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/server/resource/aws-function-code-updater.go#L112-L137","documentation":"While publishing new Lambda function code, SST polls `GetFunctionConfiguration` waiting for `LastUpdateStatus` to succeed. If the status becomes `Failed`, it raises this error embedding the `LastUpdateStatusReasonCode` and reason string from AWS. It means AWS rejected or aborted the code update itself.","triggerScenarios":"`waitForUpdate` observes `LastUpdateStatus == Failed` during Create/Update — most commonly `Failed` due to a permission error on the S3 code object, or the function being stuck in another operation, or a bad deployment package.","commonSituations":"IAM role lacking `s3:GetObject` on the deployment bucket; concurrent updates (another deploy/dev run in flight); zip package too large or corrupted; KMS key access issues on environment variables.","solutions":["Check the reason string in the error — fix the underlying AWS issue it names (often IAM permissions on the code S3 object)","Ensure no other deploy/dev session is updating the same function simultaneously, then retry","Verify the deployment package size/contents are valid for the function architecture","Check CloudTrail/function logs for the failed `UpdateFunctionCode` to pinpoint the AWS-side cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before deploying function code, ensure no update is in flight and package is valid\nconst cfg = await lambda.send(new GetFunctionConfigurationCommand({ FunctionName: name }));\nif (cfg.LastUpdateStatus === \"InProgress\") throw new Error(\"function update already in progress\");\nconst zipBytes = fs.readFileSync(zipPath);\nif (zipBytes.length > 50 * 1024 * 1024) throw new Error(\"zip exceeds direct-upload limit\");","typeGuard":null,"tryCatchPattern":"try {\n  await run(\"sst\", [\"deploy\"]);\n} catch (e) {\n  const m = /failed to update function (\\S+): (.*)/.exec(String(e));\n  if (m) {\n    console.error(`Lambda update failed for ${m[1]}: ${m[2]}. Fix permissions/package, wait for in-flight ops, then retry.`);\n    await sleep(15000);\n    await run(\"sst\", [\"deploy\"]);\n  } else throw e;\n}","preventionTips":["Grant the function's IAM role access to the deployment bucket objects","Avoid concurrent `sst dev`/`sst deploy` against the same function","Validate zip size/architecture before publish","Read the reasonCode in the error to target the exact AWS-side fix"],"tags":["aws","lambda","deployment","polling"],"backgroundTag":"lambda-update-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}