parser failed on metric definition CSV with duplicate names: agent could not parse the file and the run failed with...
Fixes an agent run that fails when its parser cannot read a metric definition CSV with duplicate names, by validating and repairing the input file before the run. Use when the run stops at the parsing step and names the file. Not for a file that parses cleanly but describes a dashboard the API later rejects.
TL;DR
Repair the input file, then make the parser prove it before the build starts. Load the metric definition CSV with a strict parser, list the duplicate names it contains, fix them in the source file or reject the file back to its owner with the list, and add a preflight validation step so the agent fails in seconds with a readable report instead of mid run. Agent builds are only as reliable as the files they are fed.
parser failed on metric definition CSV with duplicate names: agent could not parse the file and the run failed with errorUse this when
- An agent run stops at intake or early in the build with a parse error naming the metric definition CSV.
- Inspecting the file shows duplicate names that a human can spot once they are listed.
- The same class of malformed file has broken more than one run.
Not for this skill when
- The file parses and the Looker API 4.0 rejects the resulting dashboard. That is an API validation problem, not a parse failure.
- The file is generated by the agent itself in the same run. Fix the generator step rather than the parser.
Steps
- Reproduce the failure locally by loading the exact metric definition CSV from the failed run with the same parser the agent uses. Verify: the local load fails with the same error the run recorded
- Run a structural check over the file that lists the duplicate names explicitly, with locations, instead of stopping at the first defect. Verify: the check outputs a complete defect list for the file
- Repair the file at the source, correcting each listed defect, or return the defect list to the file owner if the right values are a business decision. Verify: the repaired file passes the structural check with no defects
- Add a preflight validation step to the agent that runs the check before any API call and fails the run with the defect list attached. Verify: a deliberately broken test file fails in preflight with a readable report
- Define the expected file shape as an explicit schema, covering required entries, allowed names and value types, and version it with the agent. Verify: the schema rejects a file with duplicate names and accepts the repaired file
- Rerun the original task with the repaired file and confirm the agent completes the Looker build. Verify: the run finishes and the dashboard reflects the file contents
Why it happens
Parser failures at intake are data quality problems arriving through a file. Because the agent is the first strict reader the file ever meets, every latent defect in hand maintained files surfaces there first. Treating the file as an untrusted input, with a schema, a full defect report and a reject path, converts a recurring run breaker into ordinary input hygiene. The agent code rarely needs to change at all once the intake is honest.
The agent pipeline reads the metric definition CSV to decide what to build in Looker, which fields and metrics to use, and how to lay the result out. Parsers in agent code are usually written against the happy path shape of the file, so duplicate names produce confusing low level errors or silent misreads rather than a clear intake report. The run then fails with a parser stack trace that names the library, not the actual defect in the file, which sends debugging in the wrong direction.
Operational notes for input file failures in agent pipelines. Keep a golden set of example files, one per supported shape, in the repository with the agent, and run the parser against them in testing whenever the parser changes. Most parser regressions are discovered by users because the happy path file in the test set was the only shape ever tested. Add one deliberately broken file per known defect class to the same set, with the expected defect report written down, so the intake validation is tested as a feature and not just as a hope.
Variants and edge cases
parser failed metric definition CSV duplicate names agent run
The near verbatim phrasing from the run failure.
validate metric definition CSV schema before agent build preflight
The prevention variant focused on intake validation.
agent cannot parse metric definition CSV defect list repair
The reporting variant where the parser must explain the defects.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstsnyhg6wV4P7qngTBcz20A