-
Notifications
You must be signed in to change notification settings - Fork 634
Closed
Labels
p2This is a standard priority issueThis is a standard priority issuev2-v3-inconsistencyBehavior has changed from v2 to v3, or feature is missing altogetherBehavior has changed from v2 to v3, or feature is missing altogether
Description
Pre-Migration Checklist
- I've read the Migration Guide.
- I've reviewed the upgrading notes and major version differences mentioned in
UPGRADING.md
. - I've checked AWS Forums and StackOverflow for similar migration issues.
Which JavaScript Runtime is this issue in?
Node.js (includes AWS Lambda)
AWS Lambda Usage
- Yes, my application is running on AWS Lambda.
- No, my application is not running on AWS Lambda.
Describe the Migration Issue
When sending an HeadObjectCommand
on an existing S3 object that has been uploaded without respecting POST policy conditions (size out of range in my particular case) I get a 403 "UnknownError"
with AWS SDK v3:
{
"name": "403",
"$fault": "client",
"$metadata": {
"httpStatusCode": 403,
"requestId": "XXXXX",
"extendedRequestId": "XXXXX/XXXXX/XXXXX=",
"attempts": 1,
"totalRetryDelay": 0
},
"message": "UnknownError"
}
With AWS SDK v2 the error code was "Forbidden"
.
Code Comparison
AWS SDK v2
let head;
try {
head = await s3.headObject({
Bucket : "bucketName",
Key : "key"
}).promise();
} catch (err) {
if (err.code === "Forbidden") {
// Catched!
}
throw err;
}
AWS SDK v3
const headObjectCommand = new HeadObjectCommand({
Bucket : "bucketName",
Key : "key"
});
let head;
try {
head = await s3Client.send(headObjectCommand);
} catch (err) {
if (err.name === "403" && err.message === "UnknownError") {
// Catched!
}
throw err;
}
Observed Differences/Errors
I'm using the AWS SDK v3 and typically catch errors based on their specific types, such as if (err instanceof NoSuchKey)
.
However, when handling POST policy condition violations, I encounter an ambiguous "unknown error" rather than a specific Forbidden error as expected. This lack of clarity makes it difficult to diagnose and handle POST policy condition issues effectively.
Additional Context
@aws-sdk/client-s3 v3.679.0
vousk and yuccaihaptibot
Metadata
Metadata
Assignees
Labels
p2This is a standard priority issueThis is a standard priority issuev2-v3-inconsistencyBehavior has changed from v2 to v3, or feature is missing altogetherBehavior has changed from v2 to v3, or feature is missing altogether