Skip to content

feat(block): Add cloudwatch publish operation#4027

Merged
waleedlatif1 merged 7 commits intostagingfrom
feat/cloudwatch-publish-metric
Apr 9, 2026
Merged

feat(block): Add cloudwatch publish operation#4027
waleedlatif1 merged 7 commits intostagingfrom
feat/cloudwatch-publish-metric

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Brief description of what this PR does and why.

Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

How has this been tested? What should reviewers focus on?

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 9, 2026 1:37am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Medium Risk
Adds a new CloudWatch PutMetricData API endpoint and wires it into the block/tool registry; while gated by internal auth, it introduces new AWS write-side behavior and input validation that could affect telemetry if misused or misconfigured.

Overview
Adds support for publishing custom CloudWatch metrics via a new cloudwatch_put_metric_data tool and corresponding /api/tools/cloudwatch/put-metric-data route, including validation for units and JSON dimensions and returning a structured publish result.

Updates the CloudWatch block UI/config to expose a Publish Metric operation (new fields for value/unit/dimensions), adds timestamp wand helpers for start/end time, and registers the new operation in integration metadata and the tool registry.

Tightens CloudWatch error/behavior defaults (invalid dimensions now returns 400; describe_alarms defaults to both alarm types when unspecified) and makes small consistency/docs updates (tool versions to 1.0.0, CloudFormation limit field marked advanced, Athena docs maxResults range, expanded CloudWatch docs intro).

Reviewed by Cursor Bugbot for commit 9a4d394. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c204d32. Configure here.

Theodore Li and others added 2 commits April 8, 2026 16:09
…a conventions

- Update tool version strings from '1.0' to '1.0.0' across all three integrations
- Add missing `export * from './types'` barrel re-exports (cloudwatch, cloudformation)
- Add docsLink, wandConfig timestamps, mode: 'advanced' on optional fields (cloudwatch)
- Add dropdown defaults, ZodError handling, docs intro section (cloudwatch)
- Add mode: 'advanced' on limit field (cloudformation)
- Alphabetize registry entries (cloudwatch, cloudformation)
- Fix athena docs maxResults range (1-999)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 force-pushed the feat/cloudwatch-publish-metric branch from c204d32 to f8cbbe7 Compare April 8, 2026 23:23
@waleedlatif1 waleedlatif1 marked this pull request as ready for review April 8, 2026 23:23
…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>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 8, 2026

Greptile Summary

This PR adds a Publish Metric (cloudwatch_put_metric_data) operation to the existing CloudWatch block, allowing workflows to write custom metric data points to CloudWatch. It also includes several quality fixes across the CloudWatch and CloudFormation blocks: wand configs on time fields, full StandardUnit dropdown coverage, NaN / finite-number guards, improved DescribeAlarms defaulting, and cosmetic version-string normalization across Athena and CloudFormation tools.

Confidence Score: 5/5

Safe to merge — no P0/P1 findings remain; prior review concerns (NaN guard, unit dropdown coverage, dimensions validation) are all resolved.

All previous review issues are addressed. The new put_metric_data route, tool, and block are correctly implemented following existing patterns. Validation is thorough (finite-number check, full unit enum, JSON-object dimensions guard). No new logic, security, or data-integrity issues were found.

No files require special attention.

Vulnerabilities

No security concerns identified. AWS credentials are passed via user-only visibility params and are never logged. The checkInternalAuth guard is correctly applied before any credential use. Dimensions input is Zod-validated to prevent object injection.

Important Files Changed

Filename Overview
apps/sim/app/api/tools/cloudwatch/put-metric-data/route.ts New route for publishing CloudWatch metric data; Zod schema guards NaN/Infinity values and validates dimensions as a JSON object; auth, error handling, and logging are all correct.
apps/sim/blocks/blocks/cloudwatch.ts Adds put_metric_data UI fields (value, unit dropdown with all 27 units, dimensions table), wires params correctly with NaN guard and JSON dimensions serialization, and updates outputs section.
apps/sim/tools/cloudwatch/put_metric_data.ts New tool config for cloudwatch_put_metric_data; request body mapping and transformResponse are consistent with the existing CloudWatch tool pattern.
apps/sim/tools/cloudwatch/types.ts Adds CloudWatchPutMetricDataParams and CloudWatchPutMetricDataResponse interfaces; types are correct and consistent with the route/tool implementation.
apps/sim/tools/cloudwatch/index.ts Adds putMetricDataTool import and re-export; barrel export is consistent with existing pattern.
apps/sim/blocks/blocks/cloudformation.ts Minor fix: adds mode: 'advanced' to the describe_stack_events limit field, matching the pattern used by other limit fields in the codebase.
apps/docs/content/docs/en/tools/cloudwatch.mdx Adds intro section and new cloudwatch_put_metric_data operation documentation; output fields and parameters are accurate.

Sequence Diagram

sequenceDiagram
    participant UI as Sim Block UI
    participant Block as CloudWatch Block
    participant Tool as putMetricDataTool
    participant Route as /api/tools/cloudwatch/put-metric-data
    participant CW as AWS CloudWatch

    UI->>Block: User selects Publish Metric, fills fields
    Block->>Block: params() — validate, coerce to Number, serialize dimensions
    Block->>Tool: Invoke cloudwatch_put_metric_data
    Tool->>Route: POST request with credentials and metric data
    Route->>Route: checkInternalAuth()
    Route->>Route: Zod parse — finite number, valid unit, valid JSON dimensions
    Route->>CW: PutMetricDataCommand
    CW-->>Route: 200 OK
    Route-->>Tool: success + output fields
    Tool-->>Block: transformResponse
    Block-->>UI: Outputs available
Loading

Reviews (4): Last reviewed commit: "fix(cloudwatch): use Number.isFinite to ..." | Re-trigger Greptile

…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>
Move dimensions validation from runtime try-catch to Zod refinement,
catching malformed JSON and arrays at schema validation time (400)
instead of runtime (500). Also rejects JSON arrays that would produce
meaningless numeric dimension names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 66ffcd9. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Tip:

Greploop — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

…ublishing 0

Add NaN guard in block config and .finite() refinement in Zod schema
so "abc" → NaN is caught at both layers instead of coercing to 0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@cursor review

… config

Aligns block-level validation with route's Zod .finite() refinement so
Infinity/-Infinity are caught at the block config layer, not just the API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9a4d394. Configure here.

@waleedlatif1 waleedlatif1 merged commit 139213e into staging Apr 9, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/cloudwatch-publish-metric branch April 9, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants