Skip to content

Fix missing CSV header for empty data directory in inno audit - #213

Merged
ringo380 merged 1 commit into
masterfrom
fix/audit-empty-csv
Jul 18, 2026
Merged

Fix missing CSV header for empty data directory in inno audit#213
ringo380 merged 1 commit into
masterfrom
fix/audit-empty-csv

Conversation

@ringo380

Copy link
Copy Markdown
Owner

Summary

inno audit's empty-directory branch handled --prometheus and --json (with per-mode output) but had no --csv arm. So inno audit --compliance --csv - and every other mode under --format csv - printed the plain-text No .ibd files found message on an empty datadir instead of a valid CSV header, corrupting any downstream parser.

This is the same class of gap PR #118 fixed once for --prometheus. It was surfaced during review of #211 and deferred because it lived in the shared empty-files block rather than the compliance lines that PR added.

Fix

Add an else if opts.csv arm that emits the same header the non-empty path uses for each mode (header only, no rows):

  • compliance: file,match_count,pages_with_matches,capped,error
  • health (with/without --bloat): the bloat-aware header
  • checksum-mismatch: file,page_number,stored_checksum,calculated_checksum,algorithm
  • default integrity: file,status,total_pages,empty_pages,valid_pages,invalid_pages,lsn_mismatches

Plain-text output (no --csv) is unchanged.

Testing

  • New test_audit_empty_directory_csv_emits_header covers compliance and default modes; mutation-checked (fails without the fix, passes with it).
  • fmt/clippy clean on the changed file; full audit (23) and comply (17) suites pass.
  • Verified all four modes emit the correct header against a real empty temp dir.

audit's empty-directory branch handled --prometheus and --json per mode but
had no --csv arm, so `inno audit --compliance --csv` (and every other mode
with --format csv) printed the plain-text "No .ibd files found" message on an
empty datadir instead of a valid CSV header. This corrupts downstream parsers.

Add an else-if opts.csv arm that emits the same header the non-empty path
uses for each mode (compliance, health with/without bloat, checksum-mismatch,
default integrity), with no rows. Add a regression test.
@ringo380
ringo380 merged commit 894fd70 into master Jul 18, 2026
6 of 12 checks passed
@ringo380
ringo380 deleted the fix/audit-empty-csv branch July 18, 2026 18:17
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.

1 participant