@cryptotaxi247 / netdata-1 / commits / 8bf8fe565

Fix csvjsonarray format returning invalid JSON with extra closing bracket when no data present (#21304)

* Initial plan * Fix csvjsonarray format returning extra closing bracket when no data is present Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com>

Copilot committed Nov 17, 2025 at 16:47 UTC 8bf8fe56532db0640a9ebc3b6f4c572931c56bda
1 file changed +6 -5
src/web/api/formatters/csv/csv.c
+6 -5
@@ -25,6 +25,12 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const
25 if(options & RRDR_OPTION_LABEL_QUOTES) buffer_strcat(wb, "\"");
26 i++;
27 }
28 +
29 + if(!i) {
30 + // no dimensions present
31 + return;
32 + }
33 +
34 buffer_strcat(wb, endline);
35
36 if(format == DATASOURCE_CSV_MARKDOWN) {
@@ -48,11 +54,6 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const
54 buffer_strcat(wb, endline);
55 }
56
51 - if(!i) {
52 - // no dimensions present
53 - return;
54 - }
55 -
57 long start = 0, end = rrdr_rows(r), step = 1;
58 if(!(options & RRDR_OPTION_REVERSED)) {
59 start = rrdr_rows(r) - 1;