Preserve the error that identifies a failed step

An invalid JSON string fails at decoding.

An invalid JSON string fails at decoding. Catch JSONDecodeError at that boundary and report its line and column. That locates a parsing failure before the tool implementation runs.

Work through the example

The supplied text contains one opening brace and no property. Parsing fails at line 1, column 2.

Run the example as a separate Python file. The inputs are synthetic so you can change them and see exactly which assumption affects the result.

Run the example

import json
try:
    json.loads("{")
except json.JSONDecodeError as error:
    print(error.lineno, error.colno)

Expected output

1 2

Reference: https://docs.python.org/3/library/json.html#json.JSONDecodeError

The team guide · My original notes on testing coding agents · Working with Lightbulb Partners