Skip to content

feat: add complete audit log download helper - #138

Merged
yummybomb merged 4 commits into
mainfrom
hypeship/audit-log-download-helper
Jul 21, 2026
Merged

feat: add complete audit log download helper#138
yummybomb merged 4 commits into
mainfrom
hypeship/audit-log-download-helper

Conversation

@yummybomb

@yummybomb yummybomb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add AuditLogs.Download for complete exports while retaining ExportChunk for low-level access
  • use gzip-compressed JSON Lines for high-level downloads; raw format selection remains on ExportChunk
  • verify checksums and reject missing, stalled, or cyclic cursor chains before writing each chunk
  • preserve standard SDK HTTP retry behavior and make transfer retries configurable
  • report download totals and optional progress, with partial-output behavior documented

Testing

  • go test ./...
  • go vet ./...

Note

Low Risk
New client-side SDK helper with no changes to existing APIs; risk is limited to callers adopting Download and handling documented partial-output behavior on failure.

Overview
Adds AuditLogs.Download, a high-level helper that streams a full gzip JSON Lines audit export to an io.Writer by repeatedly calling the existing ExportChunk API with cursor pagination.

Each chunk is validated before write: X-Content-Sha256 must match the body, pagination headers (X-Has-More, X-Row-Count, X-Next-Cursor) are strictly checked (including rejecting stalled or cyclic cursors), and invalid pagination fails before bytes are written. Transient read/checksum failures retry with capped exponential backoff via WithAuditLogDownloadMaxTransferRetries, while HTTP retries stay on the standard SDK request options (WithAuditLogDownloadRequestOptions). Optional WithAuditLogDownloadProgress reports cumulative bytes/chunks/rows after each verified chunk; docs note that errors can leave partial output on dst.

Tests cover multi-chunk success, checksum retry, cursor/header rejection, cursor cycles, HTTP vs transfer retry limits, and write failures.

Reviewed by Cursor Bugbot for commit 65ed54a. Bugbot is set up for automated code reviews on this repo. Configure here.

@yummybomb
yummybomb force-pushed the hypeship/audit-log-download-helper branch from b0661c3 to 2f992e4 Compare July 20, 2026 21:03
@yummybomb yummybomb changed the title Add complete audit log download helper feat: add complete audit log download helper Jul 20, 2026
@yummybomb
yummybomb marked this pull request as ready for review July 21, 2026 14:19
Comment thread auditlog_download.go
Comment thread auditlog_download.go
Comment thread auditlog_download.go

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 65ed54a. Configure here.

Comment thread auditlog_download.go
@yummybomb
yummybomb requested a review from sjmiller609 July 21, 2026 18:43
@yummybomb
yummybomb merged commit 1e6fe8c into main Jul 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants