mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cloudwatch): return ResourceNotFound for SetAlarmState on missing alarm (#1621)
* fix: return ResourceNotFound 400 for SetAlarmState on missing alarm * fix: use CloudWatch ResourceNotFound error code for missing alarm * fix: use HTTP 404 for CloudWatch ResourceNotFound Per @hectorvent's review: the CloudWatch service model (botocore cloudwatch/2010-08-01 service-2.json) declares the ResourceNotFound shape with httpStatusCode 404, so correct the AwsException status from 400 to 404 for the missing-alarm SetAlarmState path and update the test assertion to match. --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
1 parent
7d70f64162
commit
2c746b25a1
2 files changed
+13
-2
No files matched your search
+2
-1
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.cloudwatch.metrics;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -266,7 +267,7 @@ public class CloudWatchMetricsService {
|
||||
public void setAlarmState(String alarmName, String stateValue, String stateReason, String stateReasonData, String region) {
|
||||
String key = region + "::" + alarmName;
|
||||
MetricAlarm alarm = alarmStore.get(key)
|
||||
.orElseThrow(() -> new RuntimeException("Alarm not found: " + alarmName));
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFound", "Alarm not found: " + alarmName, 404));
|
||||
|
||||
alarm.setStateValue(stateValue);
|
||||
alarm.setStateReason(stateReason);
|
||||
|
||||
Reference in new issue
Block a user