license agent's parser broke on Okta System Log CSV export, seat counts wrong, audit failed
Fixes license agents that misparse Okta System Log CSV exports by replacing naive string splitting with a real CSV parser and validating row counts. Use when seat counts are wrong after a CSV parse. Not for API-side data problems.
TL;DR
The CSV contains quoted fields with embedded newlines and commas that naive splitting mishandles. Parse with a real CSV library, compare row counts against the naive parse, validate a sample against the API, and fix the counting on the correct parse.
license agent's parser broke on Okta System Log CSV export, seat counts wrong, audit failedUse this when
- Seat counts from a System Log CSV look wrong.
- The agent split the CSV by hand instead of parsing it.
- Row counts do not match the API.
Not for this skill when
- The export itself is truncated. Fix the export first.
- The API data is wrong. That is a source problem.
- The counts are right but the report is stale. That is a sync problem.
Steps
- Re-parse the export with a proper CSV library. Verify: it handles quoted fields.
- Compare row counts between the naive parse and the library parse. Verify: you can see the difference.
- Validate a sample of parsed rows against the System Log API. Verify: the parse matches reality.
- Fix the seat-count logic to run on the correct parse. Verify: counts change to sane values.
- Confirm the audit numbers. Verify: they reconcile with the API.
Variant phrasings
CSV parser broke
The short phrasing.
seat counts wrong
The symptom-first search.
System Log CSV
The source-first phrasing.
Compatibility: Okta System Log CSV exports; any CSV parsing library.
Why it happens
System Log CSVs contain JSON-ish fields with commas, quotes, and newlines inside them. Splitting on commas corrupts rows silently, and the counts built on the corruption look plausible but are wrong.
Edge cases / pitfalls
- The export encoding: check for a byte-order mark before parsing.
- Fields containing the delimiter inside quotes: the exact case libraries handle and hand-rolled code does not.
- Never hand-roll CSV parsing in agent code; the library exists for this.
- Validating only the total: also check that the right rows were counted, not just the right number.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstHU3wJR4UD2L3EvrBy6ktw