serverless/serverless · error · ServerlessError
CLOUDWATCH_DESCRIBE_LOG_GROUPS_ERROR
CLOUDWATCH_DESCRIBE_LOG_GROUPS_ERROR
Error message
Failed to describe log groups: ${error.message} What it means
Wraps any failure from CloudWatch Logs DescribeLogGroupsCommand into a ServerlessError with code CLOUDWATCH_DESCRIBE_LOG_GROUPS_ERROR. describeLogGroups forwards { logGroupNamePrefix, limit } to the logsClient; on AWS SDK failure it logs and re-throws a normalized ServerlessError with the underlying error.message.
Source
Thrown at packages/engine/src/lib/aws/cloudwatch.js:156
* Describes log groups in CloudWatch Logs
*
* @param {Object} params - Parameters for the operation
* @param {string} [params.logGroupNamePrefix] - The prefix to match
* @param {number} [params.limit] - The maximum number of log groups to return
* @returns {Promise<Object>} - The response from the DescribeLogGroups operation
* @throws {ServerlessError} If fetching log groups fails
*/
describeLogGroups = async ({ logGroupNamePrefix, limit } = {}) => {
try {
const command = new DescribeLogGroupsCommand({
logGroupNamePrefix,
limit,
})
return await this.logsClient.send(command)
} catch (error) {
logger.error(`Error describing log groups: ${error.message}`)
throw new ServerlessError(
`Failed to describe log groups: ${error.message}`,
'CLOUDWATCH_DESCRIBE_LOG_GROUPS_ERROR',
)
}
}
getRecentLogs = async ({ logGroupName, limit = 20, startTime }) => {
if (!logGroupName) {
throw new ServerlessError(
'Log group name must be provided to fetch logs',
'CLOUDWATCH_LOG_GROUP_MISSING',
)
}
const now = Date.now()
const effectiveStartTime = startTime || now - 5 * 60 * 1000 // Default to the last 5 minutes
try {View on GitHub (pinned to b9d7ea51c8)
Solutions
- Grant logs:DescribeLogGroups in the caller's IAM policy.
- Refresh credentials (aws sso login / set a valid profile).
- If passing limit, keep it within 1-50.
- Verify awsConfig.region is the region where the log groups live.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const res = await cw.describeLogGroups({ logGroupNamePrefix, limit })
} catch (err) {
if (err.code === 'CLOUDWATCH_DESCRIBE_LOG_GROUPS_ERROR') {
if (/ExpiredToken/.test(err.message)) throw new Error('AWS credentials expired - refresh profile')
if (/AccessDenied/.test(err.message)) throw new Error('Missing logs:DescribeLogGroups permission')
}
throw err
} Prevention
- Grant logs:DescribeLogGroups in the caller's IAM policy.
- Keep limit within AWS's 1-50 range.
- Confirm awsConfig.region is correct.
- Refresh credentials before long-running IDE/MCP sessions.
When it happens
Trigger: describeLogGroups({ logGroupNamePrefix, limit }) when logsClient.send(DescribeLogGroupsCommand) rejects. Typical AWS causes: missing logs:DescribeLogGroups IAM permission, expired credentials, throttling, invalid limit (must be 1-50), or network errors.
Common situations: An MCP confirmation-handler flow listing log groups without logs:DescribeLogGroups permission; credentials expiring during a long IDE session; passing a limit > 50 (AWS rejects); wrong region configured so the credentials lack access.
Related errors
- CLOUDWATCH_DESCRIBE_ALARMS_ERROR
- CLOUDWATCH_GET_LOGS_FAILED
- CLOUDWATCH_DESCRIBE_ALARM_HISTORY_ERROR
- CLOUDWATCH_GET_METRICS_FAILED
- CLOUDWATCH_GET_SQS_METRICS_FAILED
AI-assisted analysis of serverless/serverless@b9d7ea51c8 (2026-08-13).
Data as JSON: /api/errors/6939d4fe9972887e.
Report an issue: GitHub.