Be more tolerant to invalid JSON when parsing dashboards for indexing (#114040)

* Tags can only be string array.

* Be more lenient when parsing dashboard. Parse what we can, don't error out easily.

* Check element before parsing, log unexpected types.
This commit is contained in:
Peter Štibraný
2025-11-18 14:01:57 +01:00
committed by GitHub
parent e821578ab0
commit ec74a721ea
8 changed files with 586 additions and 100 deletions
+4 -1
View File
@@ -261,7 +261,10 @@ func (s *DashboardDocumentBuilder) BuildDocument(ctx context.Context, key *resou
value = rsp.Value
}
summary, err := dashboard.ReadDashboard(bytes.NewReader(value), s.DatasourceLookup)
summary, err := dashboard.ReadDashboardWithLogContext(bytes.NewReader(value), s.DatasourceLookup, map[string]any{
"document": fmt.Sprintf("%s/%s/%s/%s", key.GetNamespace(), key.GetGroup(), key.GetResource(), key.GetName()),
"rv": rv,
})
if err != nil {
return nil, err
}