jihaozh closed pull request #3662: [TE] yaml - fix detection config DTO revert
in yaml alert creation
URL: https://github.com/apache/incubator-pinot/pull/3662
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
index 9db98a967c..5dc9bdb1d5 100644
---
a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
+++
b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/yaml/YamlResource.java
@@ -144,20 +144,23 @@ public Response createYamlAlert(@ApiParam(value = "a
json contains both notific
}
detectionConfig.setYaml(detectionYaml);
Long detectionConfigId = this.detectionConfigDAO.save(detectionConfig);
+ if (detectionConfigId == null){
+ return Response.serverError().entity(ImmutableMap.of("message", "Save
detection config failed")).build();
+ }
Preconditions.checkNotNull(detectionConfigId, "Save detection config
failed");
// notification
// TODO: Inject detectionConfigId into detection alert config
DetectionAlertConfigDTO alertConfig =
createDetectionAlertConfig(yamls.get("notification"), responseMessage);
if (alertConfig == null) {
- // revert
- this.detectionAlertConfigDAO.deleteById(detectionConfigId);
+ // revert detection DTO
+ this.detectionConfigDAO.deleteById(detectionConfigId);
return
Response.status(Response.Status.BAD_REQUEST).entity(responseMessage).build();
}
Long detectionAlertConfigId =
this.detectionAlertConfigDAO.save(alertConfig);
if (detectionAlertConfigId == null){
- // revert
- this.detectionAlertConfigDAO.deleteById(detectionConfigId);
+ // revert detection DTO
+ this.detectionConfigDAO.deleteById(detectionConfigId);
return Response.serverError().entity(ImmutableMap.of("message", "Save
detection alert config failed")).build();
}
LOG.info("saved detection alert config id {}", detectionAlertConfigId);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]