Uh oh!
There was an error while loading. Please reload this page.
fix(insight): fail loudly when incident-export CSV is truncated - #168
Merged
Conversation
The export endpoint returns a one-shot CSV with no pagination cursor and caps its row count server-side, so a wide time window can come back silently truncated while the command exits 0. insight incident-export is now a curated command (same flags; the generated twin is dropped by genAddLeaf): after writing the CSV it counts the data rows with encoding/csv and compares against the incident-list total for the same filter. On a shortfall the partial CSV is still written, stderr reports the actual written count as rows=N, and the command exits non-zero stating written vs total.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
fduty insight incident-exportcould exit 0 with a silently truncated CSV: the/insight/incident/exportendpoint answers a one-shot CSV stream with no pagination cursor and caps its row count server-side without indicating so in the payload. For a wide time window the written CSV could contain far fewer rows than the number of incidents matching the filter, with no error or warning.Fix
insight incident-exportis now a curated command (identical flag surface; the generated twin is dropped bygenAddLeaf, the established curated-wins mechanism). After writing the CSV to stdout it:encoding/csv(quoted fields with embedded newlines count as one record)./insight/incident/listwith the same filter (a single 1-item page).rows=N, and the command exits non-zero with an explicit message stating written vs total and advising to narrow the time window.If completeness cannot be verified (the list call fails), the command also exits non-zero rather than letting an unverified export pass for a complete one.
Tests
New
internal/cli/insight_export_test.gocovers: complete export (exit 0,rows=Non stderr), truncated export (non-zero exit, written-vs-total message, partial CSV still written), quoted-newline row counting, filter forwarding to both endpoints, and thecountCSVDataRowsedge cases.make fmt,make lint(0 issues), andmake test(full suite,-race) all pass.