A self-hosted dashboard that puts all your feeds in one place
Go aggregatordashboarddockerfeed-readergohomelabhomepagemonitoringredditrssrss-readerself-hostedstartpageyoutube
update error reporting for custom-api JSON validation
anxdpanic7a8f70db021c
diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.goindex dbad2a3..94e97c7 100644--- a/internal/glance/widget-custom-api.go+++ b/internal/glance/widget-custom-api.go@@ -203,13 +203,18 @@ func fetchCustomAPIRequest(ctx context.Context, req *CustomAPIRequest) (*customAbody := strings.TrimSpace(string(bodyBytes))if !req.SkipJSONValidation && body != "" && !gjson.Valid(body) {- truncatedBody, isTruncated := limitStringLength(body, 100)- if isTruncated {- truncatedBody += "... <truncated>"+ if 200 <= resp.StatusCode && resp.StatusCode < 300 {+ truncatedBody, isTruncated := limitStringLength(body, 100)+ if isTruncated {+ truncatedBody += "... <truncated>"+ }++ slog.Error("Invalid response JSON in custom API widget", "url", req.httpRequest.URL.String(), "body", truncatedBody)+ return nil, errors.New("invalid response JSON")}- slog.Error("Invalid response JSON in custom API widget", "url", req.httpRequest.URL.String(), "body", truncatedBody)- return nil, errors.New("invalid response JSON")+ return nil, errors.New(fmt.Sprintf("%d %s", resp.StatusCode, http.StatusText(resp.StatusCode)))+}data := &customAPIResponseData{