-
Notifications
You must be signed in to change notification settings - Fork 634
Closed
Labels
closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.guidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.General information and guidance, answers to FAQs, or recommended best practices/resources.p2This is a standard priority issueThis is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
After updating @aws-sdk/client-s3 from 3.701.0 to 3.758.0, my AWS Lambda function started failing with the following error:
{
"errorType": "TypeError",
"errorMessage": "Object.defineProperty called on non-object",
"trace": [
"TypeError: Object.defineProperty called on non-object",
" at defineProperty (<anonymous>)",
" at __name (/var/task/src/functions/hello/handler.js:9789:37)",
" at <static_initializer> (/var/task/src/functions/hello/handler.js:9981:9)",
" at node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js (/var/task/src/functions/hello/handler.js:9976:34)",
" at __require (/var/task/src/functions/hello/handler.js:10:50)",
" at node_modules/@aws-sdk/client-s3/dist-cjs/index.js (/var/task/src/functions/hello/handler.js:21641:37)",
" at __require (/var/task/src/functions/hello/handler.js:10:50)",
" at Object.<anonymous> (/var/task/src/functions/hello/handler.js:31948:32)",
" at Module._compile (node:internal/modules/cjs/loader:1364:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)"
]
}
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
18
Reproduction Steps
- Install the latest version (3.758.0) of @aws-sdk/client-s3:
npm install @aws-sdk/client-s3@latest
- Use the following Lambda function:
import { S3 } from "@aws-sdk/client-s3";
const s3 = new S3({ region: "us-east-1" });
export const handler = async (event: { key: string }) => {
try {
const bucketName = process.env.BUCKET_NAME;
const objectKey = event.key;
if (!bucketName || !objectKey) {
throw new Error("Missing bucket name or object key");
}
const response = await s3.headObject({
Bucket: bucketName,
Key: objectKey,
});
return {
statusCode: 200,
body: JSON.stringify(response),
};
} catch (error: any) {
return {
statusCode: error.$metadata?.httpStatusCode || 500,
body: JSON.stringify({ message: error.message }),
};
}
};
- Deploy the Lambda function and invoke it with a test event:
{
"key": "path/to/object.jpg"
}
- The function fails with
TypeError: Object.defineProperty called on non-object
.
Observed Behavior
When executing a simple headObject
call to S3 using @aws-sdk/[email protected]
, the function fails with a TypeError: Object.defineProperty called on non-object.
Full error log from Lambda execution logs:
2025-03-11T00:19:56.203Z undefined ERROR Uncaught Exception {
"errorType": "TypeError",
"errorMessage": "Object.defineProperty called on non-object",
"stack": [
"TypeError: Object.defineProperty called on non-object",
" at defineProperty (<anonymous>)",
" at __name (/var/task/src/functions/hello/handler.js:9789:37)",
" at <static_initializer> (/var/task/src/functions/hello/handler.js:9981:9)",
" at node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js (/var/task/src/functions/hello/handler.js:9976:34)",
" at __require (/var/task/src/functions/hello/handler.js:10:50)",
" at node_modules/@aws-sdk/client-s3/dist-cjs/index.js (/var/task/src/functions/hello/handler.js:21641:37)",
" at __require (/var/task/src/functions/hello/handler.js:10:50)",
" at Object.<anonymous> (/var/task/src/functions/hello/handler.js:31948:32)",
" at Module._compile (node:internal/modules/cjs/loader:1364:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)"
]
}
Expected Behavior
The function should successfully execute and return metadata from headObject
, as it does in @aws-sdk/client-s3
version 3.701.0.
Possible Solution
Workaround
Downgrading to version 3.701.0
resolves the issue:
npm install @aws-sdk/[email protected]
Additional Information/Context
No response
ronnyroeller, taylor-rackley-FHR, PhilBeaudoin, flyrmi, panamclipper707 and 5 more
Metadata
Metadata
Assignees
Labels
closing-soonThis issue will automatically close in 4 days unless further comments are made.This issue will automatically close in 4 days unless further comments are made.guidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.General information and guidance, answers to FAQs, or recommended best practices/resources.p2This is a standard priority issueThis is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.