fix: improve NoSuchKey error handling in S3 mock

This commit is contained in:
David Snelling 2025-08-09 14:36:54 -07:00
parent af7a1e1cbc
commit c474f3692a

View file

@ -240,8 +240,10 @@ function handleGetObject(command: any) {
if (!bucket.objects.has(Key)) { if (!bucket.objects.has(Key)) {
console.log(`Object ${Key} not found in bucket ${Bucket}`) console.log(`Object ${Key} not found in bucket ${Bucket}`)
// Return null for non-existent objects instead of rejecting // Create proper NoSuchKey error that matches AWS SDK structure
return Promise.reject(new Error(`NoSuchKey: The specified key does not exist.`)) const error = new Error(`NoSuchKey: The specified key does not exist.`)
error.name = 'NoSuchKey'
return Promise.reject(error)
} }
const object = bucket.objects.get(Key)! const object = bucket.objects.get(Key)!