Uh oh!
There was an error while loading. Please reload this page.
fix(cloudwatch): use PutAlarmMuteRule for mute/unmute with duration window - #4621
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 7974bef. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR replaces the previous
Confidence Score: 3/5The mute route has two issues that could prevent mute rules from ever activating: a missing seconds component in the schedule expression and a potential timing conflict when a user-supplied startDate is passed as both the at() trigger and the rule's StartDate field. The at() expression built by toAtExpression omits the seconds field — AWS docs require at(yyyy-mm-ddThh:mm:ss) — likely causing every mute-rule creation to be rejected by the CloudWatch API. Additionally, when a user provides a startDate, the code sets both Schedule.Expression = at(startDate) and StartDate = startDate to the same instant; because StartDate means the rule only takes effect after that point, the at() trigger may fire before the rule is considered active, silently producing a no-op. apps/sim/app/api/tools/cloudwatch/mute-alarm/route.ts — both the expression format and the StartDate logic need attention before this is production-safe. Important Files Changed
Sequence DiagramsequenceDiagram
participant Block as CloudWatch Block
participant Route as /api/tools/cloudwatch/mute-alarm
participant CW as AWS CloudWatch
Block->>Route: "POST {muteRuleName, alarmNames, durationValue, durationUnit, startDate?}"
Route->>Route: Zod validate (incl. 15-day cap)
Route->>Route: toAtExpression(startDate ?? now) → at(YYYY-MM-DDThh:mm)
Route->>Route: toIsoDuration(value, unit) → PTxH / PxD / PTxM
Route->>CW: "PutAlarmMuteRuleCommand {Name, Rule.Schedule, MuteTargets, StartDate?}"
CW-->>Route: 200 OK
Route-->>Block: "{success, muteRuleName, alarmNames, expression, duration}"
Note over Block,Route: Unmute flow
Block->>Route: "POST {muteRuleName}"
Route->>CW: "DeleteAlarmMuteRuleCommand {AlarmMuteRuleName}"
CW-->>Route: 200 OK
Route-->>Block: "{success, muteRuleName}"
Reviews (1): Last reviewed commit: "fix(cloudwatch): use PutAlarmMuteRule fo..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
PutAlarmMuteRule) instead of disabling alarm actions, so mutes auto-expire after a fixed durationDeleteAlarmMuteRule)muteRuleName, comma-separatedalarmNames,durationValue+durationUnitdropdown (minutes/hours/days), optional description, optionalstartDate(Unix epoch — defaults to now); capped at AWS's 15-day limitmuteRuleNameType of Change
Testing
Tested manually.
bun run lintandbun run check:api-validation:strictpass.Checklist