From 8e16d34dc7585eb5fe7778c5da7965e31460d601 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:56:16 -0400 Subject: [PATCH] Fix WO fallback-rate alarm math expression (deploy hotfix) (#102) The EmailProcessorTemplateFallbackRateAlarm added in #99 used MAX([FILL(fb,0)+FILL(tmpl,0),1]) as a divide-by-zero guard, but CloudWatch metric math has no element-wise MAX over an array; it rejects the array operand at deploy time with 'Unsupported operand type(s) for MAX', failing the WorkorderIngestStack update (it rolled back cleanly). The outer IF((...)>=10, ...) volume floor already guarantees a non-zero denominator in the true branch, so divide by (FILL(fb,0)+FILL(tmpl,0)) directly and drop the invalid guard. Unblocks the #99 deploy (PO stack already applied; WO rolled back). --- cdk/wo_stack.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cdk/wo_stack.py b/cdk/wo_stack.py index def3964..05d8ac2 100644 --- a/cdk/wo_stack.py +++ b/cdk/wo_stack.py @@ -418,8 +418,12 @@ class WorkorderIngestStack(Stack): ) fallback_rate = cloudwatch.MathExpression( expression=( + # The IF volume floor (>=10) already guarantees the denominator + # is non-zero in the true branch, so divide directly. (An earlier + # MAX([...,1]) divide-by-zero guard used array syntax CloudWatch + # rejects at deploy: "Unsupported operand type(s) for MAX".) "IF((FILL(fb,0)+FILL(tmpl,0))>=10, " - "100*FILL(fb,0)/MAX([FILL(fb,0)+FILL(tmpl,0),1]), 0)" + "100*FILL(fb,0)/(FILL(fb,0)+FILL(tmpl,0)), 0)" ), using_metrics={"fb": fb_metric, "tmpl": tmpl_metric}, period=Duration.minutes(15),