From c474f3692a9d8db8d2a447170bfda1035f13140d Mon Sep 17 00:00:00 2001 From: David Snelling Date: Sat, 9 Aug 2025 14:36:54 -0700 Subject: [PATCH] fix: improve NoSuchKey error handling in S3 mock --- tests/mocks/s3-mock.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/mocks/s3-mock.ts b/tests/mocks/s3-mock.ts index 0a28b347..a4c105ee 100644 --- a/tests/mocks/s3-mock.ts +++ b/tests/mocks/s3-mock.ts @@ -240,8 +240,10 @@ function handleGetObject(command: any) { if (!bucket.objects.has(Key)) { console.log(`Object ${Key} not found in bucket ${Bucket}`) - // Return null for non-existent objects instead of rejecting - return Promise.reject(new Error(`NoSuchKey: The specified key does not exist.`)) + // Create proper NoSuchKey error that matches AWS SDK structure + const error = new Error(`NoSuchKey: The specified key does not exist.`) + error.name = 'NoSuchKey' + return Promise.reject(error) } const object = bucket.objects.get(Key)!