From 7a242327350a9274a4e7726f4fcc3762f26e8b58 Mon Sep 17 00:00:00 2001 From: Steven Klaiber-Noble Date: Tue, 8 Jul 2025 14:06:25 -0700 Subject: [PATCH] fix: check Lambda execution errors in S3 uploader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The upload function now properly checks the result of lambda.send() and throws an exception when the Lambda execution fails. This ensures that errors from the batch processor are properly propagated up the call stack. The error handling follows the same pattern as script-function/index.ts: - Parses the error payload to extract errorType and errorMessage - Includes the source bucket/key in the error for better debugging - Uses the error.reason pattern consistent with the codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../sst/support/custom-resources/s3-uploader.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/sst/support/custom-resources/s3-uploader.ts b/packages/sst/support/custom-resources/s3-uploader.ts index 9531f9e23..dcb4fe293 100644 --- a/packages/sst/support/custom-resources/s3-uploader.ts +++ b/packages/sst/support/custom-resources/s3-uploader.ts @@ -77,7 +77,7 @@ async function uploadFiles(props: Props) { fileOptions, replaceValues, } = props; - await Promise.all( + const results = await Promise.all( sources.map((source) => lambda.send( new InvokeCommand({ @@ -96,6 +96,18 @@ async function uploadFiles(props: Props) { ) ) ); + + // Check for Lambda execution errors + results.forEach((result, index) => { + if (result.FunctionError) { + const source = sources[index]; + const payload = JSON.parse(Buffer.from(result.Payload!).toString()); + const error = new Error(); + // @ts-ignore + error.reason = `${payload.errorType}: ${payload.errorMessage} [${source.bucketName}/${source.objectKey}]`; + throw error; + } + }); } async function purgeOldFiles(props: Props) {