Skip to content

Commit 0aecc0f

Browse files
waleedlatif1claude
andcommitted
fix(cloudwatch): fix DescribeAlarms returning only MetricAlarm when "All Types" selected
Per AWS docs, omitting AlarmTypes returns only MetricAlarm. Now explicitly sends both MetricAlarm and CompositeAlarm when no filter is selected. Also fix dimensions JSON parse errors returning 500 instead of 400 in get-metric-statistics route. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5aa5347 commit 0aecc0f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

  • apps/sim/app/api/tools/cloudwatch

apps/sim/app/api/tools/cloudwatch/describe-alarms/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export async function POST(request: NextRequest) {
5151
const command = new DescribeAlarmsCommand({
5252
...(validatedData.alarmNamePrefix && { AlarmNamePrefix: validatedData.alarmNamePrefix }),
5353
...(validatedData.stateValue && { StateValue: validatedData.stateValue as StateValue }),
54-
...(validatedData.alarmType && { AlarmTypes: [validatedData.alarmType as AlarmType] }),
54+
AlarmTypes: validatedData.alarmType
55+
? [validatedData.alarmType as AlarmType]
56+
: (['MetricAlarm', 'CompositeAlarm'] as AlarmType[]),
5557
...(validatedData.limit !== undefined && { MaxRecords: validatedData.limit }),
5658
})
5759

apps/sim/app/api/tools/cloudwatch/get-metric-statistics/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function POST(request: NextRequest) {
5353
}))
5454
}
5555
} catch {
56-
throw new Error('Invalid dimensions JSON')
56+
return NextResponse.json({ error: 'Invalid dimensions JSON format' }, { status: 400 })
5757
}
5858
}
5959

0 commit comments

Comments
 (0)