agent failed to parse the expense export: nested json error
Fixes agent failures parsing nested JSON expense exports with defensive parsing and schema validation. Use when an agent errors on nested or irregular JSON in an expense export. Not for CSV format changes.
TL;DR
The export's JSON nests deeper (or more irregularly) than the parser expects. Parse defensively: walk the structure with safe accessors, validate against a schema, and skip-and-log malformed records instead of aborting the run.
Error
agent failed to parse the expense export: nested json errorSteps
- Capture the failing JSON record and inspect its nesting. Expected: you see the unexpected depth or shape.
- Replace direct key access with safe accessors that return a default on missing keys. Expected: missing fields no longer raise.
- Add schema validation for the record shape you expect; log and skip records that fail validation. Expected: bad records are quarantined, good ones parse.
- Handle the nesting generically: flatten known nested objects (line items, custom fields) into a uniform record. Expected: downstream code sees one shape.
- Alert on the skip rate: a sudden spike means the export format changed. Expected: format drift pages someone instead of silently dropping data.
When to use
- An agent errors parsing nested JSON expense exports.
- One malformed record kills the whole parse.
When not to use
- The export is CSV with changed columns (see the format-change skill).
- The JSON is truncated mid-stream (see the truncated-JSON skill).
Tool compatibility
- Custom agent ingest; JSON expense exports and APIs.
Variant phrasings
JSON parse error on expense export
Same failure, generic wording.
Unexpected nesting in export data
Names the structural cause.
Why it happens
Expense exports nest line items, custom fields, and audit trails to arbitrary depth, and vendors change the shape. Rigid parsers break on the first surprise; defensive parsers absorb it.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_dNyfCmHIg8pB2AcUeBYBgQ