| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The csvjsonarray formatter adds RRDR_OPTION_LABEL_QUOTES to the options it passes to rrdr2csv using arithmetic addition instead of bitwise OR. When the caller already passes label-quotes (redundant but legal), the addition clears the bit and carries into the next one, so the header row is emitted without quotes - [time,a,b,c] - making the entire response invalid JSON. The carried-into bit is inert at format time, so the values themselves stay correct. Reachable on /api/v1, /api/v2 and /api/v3 data queries with format=csvjsonarray and options=label-quotes, at both call sites (with and without jsonwrap).
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
The csvjsonarray formatter adds RRDR_OPTION_LABEL_QUOTES to the options it passes to rrdr2csv() using arithmetic addition instead of bitwise OR (options + RRDR_OPTION_LABEL_QUOTES, two call sites in rrd2json.c). When the caller already passes label-quotes — redundant but legal, since csvjsonarray always wants quoted labels — the addition clears the bit and carries into the next one. The header row is then emitted without quotes:
— making the entire response invalid JSON. The carried-into bit is inert at format time (value conversion reads the query window options, which are untouched), so the values themselves stay correct.
Reachable on /api/v1, /api/v2 and /api/v3 data queries with format=csvjsonarray&options=label-quotes, at both call sites (with and without jsonwrap).
Fix
+ → | at both sites. A repository-wide search confirms these are the only two occurrences of arithmetic on RRDR_OPTION_* bits.
Validation
Red/green with a deterministic fixture (one chart, three dimensions, fixed 2023 epoch), covering both call sites:
Related finding (not addressed here)
While validating this, a separate defect surfaced: /api/v{2,3}/data?format=csvjsonarray without seconds emits unquoted datetime strings ([2023-11-15 00:14:20,1,2,5]) — invalid JSON regardless of this fix. v1 avoids it only because its defaults include seconds. That needs a small contract decision (quote the dates vs default csvjsonarray to seconds on v2/v3) and will be handled separately.
Summary by cubic
Fixes invalid JSON from csvjsonarray when callers pass label-quotes by using bitwise OR to keep header labels quoted. /api/v1, /api/v2, and /api/v3 responses are now valid JSON in this case.
Written for commit 7e38c70. Summary will update on new commits.