Skip to content

Commit 5aa5347

Browse files
waleedlatif1claude
andcommitted
fix(cloudwatch): complete put_metric_data unit dropdown, add missing outputs, fix JSON error handling
- Add all 27 valid CloudWatch StandardUnit values to metricUnit dropdown (was 13) - Add missing block outputs for put_metric_data: success, namespace, metricName, value, unit - Add try-catch around dimensions JSON.parse in put-metric-data route for proper 400 errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f8cbbe7 commit 5aa5347

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

apps/sim/app/api/tools/cloudwatch/put-metric-data/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ export async function POST(request: NextRequest) {
7373

7474
const dimensions: { Name: string; Value: string }[] = []
7575
if (validatedData.dimensions) {
76-
const parsed = JSON.parse(validatedData.dimensions)
76+
let parsed: unknown
77+
try {
78+
parsed = JSON.parse(validatedData.dimensions)
79+
} catch {
80+
return NextResponse.json({ error: 'Invalid dimensions JSON format' }, { status: 400 })
81+
}
7782
if (typeof parsed === 'object' && parsed !== null) {
7883
for (const [name, value] of Object.entries(parsed)) {
7984
dimensions.push({ Name: name, Value: String(value) })

apps/sim/blocks/blocks/cloudwatch.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,22 @@ Return ONLY the numeric timestamp - no explanations, no quotes, no extra text.`,
271271
{ label: 'Kilobytes', id: 'Kilobytes' },
272272
{ label: 'Megabytes', id: 'Megabytes' },
273273
{ label: 'Gigabytes', id: 'Gigabytes' },
274+
{ label: 'Terabytes', id: 'Terabytes' },
274275
{ label: 'Bits', id: 'Bits' },
276+
{ label: 'Kilobits', id: 'Kilobits' },
277+
{ label: 'Megabits', id: 'Megabits' },
278+
{ label: 'Gigabits', id: 'Gigabits' },
279+
{ label: 'Terabits', id: 'Terabits' },
275280
{ label: 'Bytes/Second', id: 'Bytes/Second' },
281+
{ label: 'Kilobytes/Second', id: 'Kilobytes/Second' },
282+
{ label: 'Megabytes/Second', id: 'Megabytes/Second' },
283+
{ label: 'Gigabytes/Second', id: 'Gigabytes/Second' },
284+
{ label: 'Terabytes/Second', id: 'Terabytes/Second' },
285+
{ label: 'Bits/Second', id: 'Bits/Second' },
286+
{ label: 'Kilobits/Second', id: 'Kilobits/Second' },
287+
{ label: 'Megabits/Second', id: 'Megabits/Second' },
288+
{ label: 'Gigabits/Second', id: 'Gigabits/Second' },
289+
{ label: 'Terabits/Second', id: 'Terabits/Second' },
276290
{ label: 'Count/Second', id: 'Count/Second' },
277291
],
278292
value: () => 'None',
@@ -678,6 +692,26 @@ Return ONLY the numeric timestamp - no explanations, no quotes, no extra text.`,
678692
type: 'array',
679693
description: 'CloudWatch alarms with state and configuration',
680694
},
695+
success: {
696+
type: 'boolean',
697+
description: 'Whether the published metric was successful',
698+
},
699+
namespace: {
700+
type: 'string',
701+
description: 'Metric namespace',
702+
},
703+
metricName: {
704+
type: 'string',
705+
description: 'Metric name',
706+
},
707+
value: {
708+
type: 'number',
709+
description: 'Published metric value',
710+
},
711+
unit: {
712+
type: 'string',
713+
description: 'Metric unit',
714+
},
681715
timestamp: {
682716
type: 'string',
683717
description: 'Timestamp when metric was published',

0 commit comments

Comments
 (0)