| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Without seconds or ms in the request options, the csv renderer emits the timestamp as a bare local-time date string - [2023-11-15 00:14:20,1,2,5] - making the whole csvjsonarray response invalid JSON, on all API versions. Nothing can depend on that output: it was never parseable, neither as JSON nor as JavaScript. JSON has no date type, so this format now defaults to numeric seconds timestamps; ms is honored when requested. The google visualization formats (datatable/datasource with google_json), whose Date(y,m,d,...) cells are deliberately not strict JSON per that API's contract, are untouched.
|
Sorry, something went wrong.
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Confidence score: 5/5
sequenceDiagram
participant Client as HTTP Client
participant API as API Handler
participant RRDR as RRDR Engine
participant CSV as csv Formatter
participant Buffer as JSON Buffer
Note over Client,Buffer: csvjsonarray Timestamp Defaulting Flow
Client->>API: GET /api/v1/data?format=csvjsonarray
API->>RRDR: data_query_execute()
RRDR->>RRDR: Check DATASOURCE_CSV_JSON_ARRAY case
Note over RRDR: Compute csv_options<br/>Start with LABEL_QUOTES
RRDR->>RRDR: Check options & RRDR_OPTION_MILLISECONDS
alt MS option NOT set
RRDR->>RRDR: Default to RRDR_OPTION_SECONDS<br/>(numeric epoch timestamp)
else MS option IS set
RRDR->>RRDR: Keep RRDR_OPTION_MILLISECONDS<br/>(millisecond precision)
end
alt JSON_WRAP option set
RRDR->>Buffer: wrapper_begin() / json_array
RRDR->>CSV: rrdr2csv() with csv_options
CSV->>Buffer: Emit numeric timestamps
RRDR->>Buffer: wrapper_end()
else No JSON_WRAP
RRDR->>Buffer: buffer_strcat("[")
RRDR->>CSV: rrdr2csv() with csv_options
CSV->>Buffer: Emit numeric timestamps
RRDR->>Buffer: buffer_strcat("]")
end
Buffer-->>API: Valid JSON with numeric timestamps
API-->>Client: 200 + application/json<br/>"result" array with epoch timestamps
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
format=csvjsonarray without seconds or ms in the options emits the timestamp as a bare, unquoted, local-time date string:
— making the entire response invalid JSON, on all API versions (verified live on v1, v2 and v3). There is no code-level default adding seconds anywhere; the dashboards always passed it explicitly, which is why this never surfaced. Nothing can depend on the current no-timestamp-option output: it was never parseable — not as JSON, and not as JavaScript either (2023-11-15 00:14:20 is a syntax error as a JS expression), so not even eval-based consumers could ever have read it.
Fix
JSON has no date type, so csvjsonarray now defaults to numeric seconds timestamps; ms is honored when requested. Applied once in the csvjsonarray branch of rrd2json.c, covering both call sites (with and without jsonwrap).
The Google Visualization formats (datatable/datasource with google_json), whose Date(y,m,d,...) cells are deliberately not strict JSON per that API's contract, are untouched.
Validation
Red/green with a deterministic fixture (one chart, three dimensions, fixed 2023 epoch):
Summary by cubic
Ensure format=csvjsonarray always outputs numeric timestamps so responses are valid JSON. Defaults to seconds when no option is provided; ms still works.
Written for commit a1f2724. Summary will update on new commits.