@aws-sdk/client-s3
| Property | Value |
|---|---|
| Package | @aws-sdk/client-s3 |
| Versions Covered | ^3.0.0 |
| Contract Version | 1.0.0 |
| Status | production |
| Last Verified | 2026-02-25 |
| Maintainer | corpus-team |
Installationâ
npm install @aws-sdk/client-s3
Covered Functionsâ
This contract covers 2 function(s):
send()â
Sends S3 commands (GetObject, PutObject, DeleteObject, etc.) to AWS S3
Import:
import { send } from '@aws-sdk/client-s3';
Postconditionsâ
What happens after calling this function:
đ´ ERROR - s3-object-operation-no-try-catch
Condition: s3Client.send() called with object operation commands without try-catch
Throws: NoSuchKey (404), AccessDenied (403), NoSuchBucket (404), network errors
Required Handling:
MUST wrap await s3Client.send() in try-catch block when using GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, or CopyObjectCommand. Catch block should check error.name for specific error types (NoSuchKey, AccessDenied, NoSuchBucket) and handle appropriately.
đ Source
đ´ ERROR - s3-multipart-no-try-catch
Condition: s3Client.send() called with multipart commands without try-catch
Throws: NoSuchUpload (404), EntityTooSmall (400), InvalidPart (400)
Required Handling:
MUST wrap multipart upload operations in try-catch block. Catch block MUST call AbortMultipartUploadCommand with the uploadId to clean up orphaned parts. This prevents storage charges for incomplete uploads.
đ Source
đ´ ERROR - s3-bucket-operation-no-try-catch
Condition: s3Client.send() called with bucket operations without try-catch
Throws: BucketAlreadyExists (409), BucketNotEmpty (409), NoSuchBucket (404)
Required Handling:
MUST wrap bucket operations in try-catch block. Handle BucketAlreadyExists/BucketAlreadyOwnedByYou gracefully (may be acceptable), check BucketNotEmpty before deletion, validate permissions.
đ Source
â ī¸ WARNING - s3-list-operation-no-try-catch
Condition: s3Client.send() called with list operations without try-catch
Throws: NoSuchBucket (404), AccessDenied (403), InvalidArgument (400)
Required Handling:
SHOULD wrap list operations in try-catch block for robustness. Handle NoSuchBucket and AccessDenied errors gracefully. Implement pagination properly with ContinuationToken.
đ Source
S3Client()â
Initializes AWS S3 client
Import:
import { S3Client } from '@aws-sdk/client-s3';
Postconditionsâ
What happens after calling this function:
âšī¸ INFO - s3-client-no-retry-config
Condition: S3Client created without retry configuration
Required Handling:
CONSIDER configuring retry settings: new S3Client( region, maxAttempts: 3, retryMode: 'adaptive' ). Adaptive mode adjusts retry attempts based on throttling signals from AWS.
đ Source
â ī¸ WARNING - s3-client-missing-region
Condition: S3Client created without explicit region
Required Handling:
SHOULD explicitly set region: new S3Client( region: 'us-east-1' ) or use environment variable with fallback.
đ Source
Example: Proper Error Handlingâ
import client-s3 from '@aws-sdk/client-s3';
async function example() {
try {
const result = await send(/* args */);
// Handle success
return result;
} catch (error) {
// Handle error according to contract postconditions
console.error('Error:', error);
throw error;
}
}