serverless/serverless · error · Error
The bucket "${bucketName}" does not exist. Please check the
Error message
The bucket "${bucketName}" does not exist. Please check the bucket name and try again. What it means
Thrown by checkBucketVersioning() when the underlying GetBucketVersioningCommand call fails with NoSuchBucket. The method catches the AWS error and re-throws a plain Error (not ServerlessError, no error code) whose message states the bucket does not exist. Because it is a plain Error, callers cannot match on .code and must inspect the message.
Source
Thrown at packages/engine/src/lib/aws/s3.js:93
versioningParams,
)
const versioningResponse = await this.client.send(getVersioningCommand)
// Check if versioning is enabled
const versioningStatus = versioningResponse.Status
if (versioningStatus === BucketVersioningStatus.Enabled) {
return true
} else if (versioningStatus === BucketVersioningStatus.Suspended) {
return false
} else {
return false
}
} catch (err) {
const name = err.name
// Check if the error is due to the bucket not existing
if (err instanceof NoSuchBucket || name === 'NoSuchBucket') {
throw new Error(
`The bucket "${bucketName}" does not exist. Please check the bucket name and try again.`,
)
} else {
// Re-throw any other errors
throw new Error(
`An error occurred while checking versioning for bucket "${bucketName}": ${err.message}`,
)
}
}
}
/**
* Checks if an S3 bucket exists.
*
* @param {Object} params - The parameters for checking if the bucket exists.
* @param {string} params.bucketName - The name of the S3 bucket.
* @returns {Promise<boolean>} - Returns true if the bucket exists, false otherwise.
*/View on GitHub (pinned to b9d7ea51c8)
Solutions
- Verify the bucket name spelling and that it exists in the AWS account the engine is authenticated to.
- Run aws s3api list-buckets (or check the console) with the same credentials to confirm ownership.
- Call checkIfBucketExists({ bucketName }) before calling checkBucketVersioning to fail fast with a clear signal.
- Confirm the bucket has not been deleted and that the region matches.
Defensive patterns
Strategy: validation
Validate before calling
const exists = await s3.checkIfBucketExists({ bucketName })
if (!exists) throw new Error(`Bucket ${bucketName} not found; fix the name/region/account`)
// only then:
await s3.checkBucketVersioning({ bucketName }) Type guard
// Plain Error with no .code — match on message.
function isBucketNotFound(e) {
return e instanceof Error && /does not exist/.test(e.message)
} Try / catch
try {
return await s3.checkBucketVersioning({ bucketName })
} catch (e) {
if (isBucketNotFound(e)) { /* bucket missing: fix name/region/account */ }
throw e
} Prevention
- Call checkIfBucketExists before any bucket-property read to fail fast with intent.
- Keep bucket names in config rather than computing them ad hoc to avoid typos.
- Confirm the deploy credentials own the bucket.
When it happens
Trigger: GetBucketVersioningCommand rejects with err.name === 'NoSuchBucket' (or an instance of NoSuchBucket) for the supplied bucketName.
Common situations: Wrong bucket name (typo); bucket lives in a different AWS account than the credentials in use; bucket was deleted; bucket name correct but the deploy target region differs (S3 names are globally unique but access is account-scoped); credentials point to the wrong account.
Related errors
- An error occurred while checking versioning for bucket "${bu
- An error occurred while getting versioning for bucket "${buc
- An error occurred while checking if bucket "${bucketName}" e
- An error occurred while getting location for bucket "${bucke
- An error occurred while getting ACL for bucket "${bucketName
AI-assisted analysis of serverless/serverless@b9d7ea51c8 (2026-08-13).
Data as JSON: /api/errors/f0e24419c9a6bbd8.
Report an issue: GitHub.