[TE] quick fix for error in retriving legacy anomaly
This PR provides quick fix when a legacy anomaly is retrieved and there is no detection associated with it. In that case, the backend just skip all legacy/invalid anomalies.
@@ -236,8 +236,15 @@ public class UserDashboardResource {
if (anomaly.getDetectionConfigId() != null) {
long detectionConfigId = anomaly.getDetectionConfigId();
DetectionConfigDTO detectionDTO = this.detectionDAO.findById(detectionConfigId);
+ if (detectionDTO != null) {
summary.setFunctionName(detectionDTO.getName());
summary.setDetectionConfigId(detectionConfigId);
+ } else {
+ // this can happen when legacy anomalies are retrieved
+ LOG.error("Cannot find detectionConfig with id {}, so skipping the anomaly {}...",
+ detectionConfigId, anomaly.getId());
+ continue;
+ }
}
summary.setMetricName(anomaly.getMetric());
