Graphite: Fix legacy response unmarshalling (#112968)

Fix legacy response unmarshalling
This commit is contained in:
Andreas Christou
2025-10-24 12:28:04 -05:00
committed by GitHub
parent e23ba8aa6c
commit d2dbb816b2
3 changed files with 78 additions and 2 deletions
+8 -2
View File
@@ -256,8 +256,14 @@ func (s *Service) parseResponse(res *http.Response) ([]TargetResponseDTO, error)
var data []TargetResponseDTO
err = json.Unmarshal(body, &data)
if err != nil {
s.logger.Info("Failed to unmarshal graphite response", "error", err, "status", res.Status, "body", string(body))
return nil, backend.DownstreamError(err)
s.logger.Warn("Failed to unamrshal to newer graphite response, attempting legacy")
var legacyData LegacyTargetResponseDTO
err = json.Unmarshal(body, &legacyData)
if err != nil {
s.logger.Info("Failed to unmarshal legacy graphite response", "error", err, "status", res.Status, "body", string(body))
return nil, backend.PluginError(err)
}
return legacyData.Series, nil
}
return data, nil