Skip to content

Commit ae650be

Browse files
ZviBaratzclaude
andcommitted
fix(ego-field-test): indent multi-line expressions in json_extract wrapper
The json_extract helper (introduced in 685d3dc) wraps Python expressions in try/except but relied on template whitespace to indent the first line. Multi-line expressions had subsequent lines at column 0, outside the try block, causing IndentationError for all but the first few extensions. Pipe expressions through sed to indent every line by 4 spaces. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c54d848 commit ae650be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/field-test-runner.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ HISTORY_FILE="$ROOT_DIR/field-tests/history.jsonl"
3434
json_extract() {
3535
local context="$1"; shift
3636
local expr="$1"; shift
37+
local indented
38+
indented="$(printf '%s\n' "$expr" | sed '/^[[:space:]]*$/d' | sed 's/^/ /')"
3739
python3 -c "
3840
import json, sys
3941
try:
40-
$expr
42+
$indented
4143
except (json.JSONDecodeError, KeyError, IndexError, TypeError) as e:
4244
print(f'Error ($context): {type(e).__name__}: {e}', file=sys.stderr)
4345
sys.exit(1)

0 commit comments

Comments
 (0)