File handle leak at scale
You asked an AI agent for a Python helper that reads the first line of each file in a directory and returns a dict of filename to header, for an ETL job processing thousands of CSVs. It produced:
It works on a folder of 5 files. What breaks at ETL scale, and what else is wrong?
Implement
read_headers_safely(names: list[str], first_lines: list[str], is_file: list[bool]) → list[str]Examples
in
[["a.csv","b.csv"],["id,name "," x,y\n"],[true,true]]out["a.csv=id,name","b.csv=x,y"]in
[["data.csv","logs",".hidden.csv"],["id,ts","","id,ts"],[true,false,true]]out["data.csv=id,ts"]in
[["a.csv","b.csv"],["","h1"],[true,true]]out["b.csv=h1"]What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
0:00 of about 15 min
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.