Repository navigation
Commit eeeac64
committed
fix(data_classes): return None from CloudWatchAlarmMetric.metric_stat for expression entries
`metric_stat` read `self["metricStat"]` directly, so it raised `KeyError` on the
expression entries of a metric math alarm. `expression` and `label` in the same
class already use `self.get(...)` for optional keys; this makes `metric_stat`
consistent with them.
The repository's own `cloudWatchAlarmEventSingleMetric.json` fixture has this
shape — its first metric (`e1`, `expression: "m1/m2"`) has no `metricStat` — so
the new test reproduces it without any synthetic payload.
Signed-off-by: ShussMiao <168898188+ShussMiao@users.noreply.github.com>1 parent 26deef8 commit eeeac64
2 files changed
Lines changed: 26 additions & 2 deletions
File tree
- aws_lambda_powertools/utilities/data_classes
- tests/unit/data_classes/required_dependencies
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
61 | 78 | | |
62 | 79 | | |
| |||
0 commit comments