Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion autonomy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9740,7 +9740,15 @@ def process_stream():
elif tool == "Bash":
tool_desc = tool_input.get("description", tool_input.get("command", "")[:60])
elif tool == "Grep":
tool_desc = f"pattern: {tool_input.get('pattern', '')}"
# NOTE: This Python block runs as the argument of
# bash `python3 -u -c`, wrapped in a bash single-
# quoted string. Any single-quoted Python literal
# here would close bash SQ mid-code and Python
# would receive `tool_input.get(pattern, )`, a
# bare identifier instead of a string literal,
# crashing with NameError. Use double quotes and
# string concatenation to stay SQ-safe.
tool_desc = "pattern: " + tool_input.get("pattern", "")
elif tool == "Glob":
tool_desc = tool_input.get("pattern", "")

Expand Down
37 changes: 35 additions & 2 deletions tests/test-bugfix-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,47 @@ test_source "BUG-CMD-012: worktree merge uses env var for signal file" \
test_source "BUG-GH-011: gh status has space before version" \
'installed \$\(gh --version'

# -------------------------------------------
# BUG-RUN-004: Claude stream processor Grep branch used a single-quoted
# Python literal inside a bash single-quoted heredoc (python3 -u -c '...'),
# silently breaking bash SQ and making Python see a bare identifier instead
# of the "pattern" string, crashing with NameError on every Grep tool call.
# Fix: use double quotes and concatenation, no single-quoted literals in
# the Python block.
# -------------------------------------------
RUN_SH="$SCRIPT_DIR/../autonomy/run.sh"

((TOTAL++))
if grep -qE 'tool_input\.get\("pattern", ""\)' "$RUN_SH"; then
log_pass "BUG-RUN-004: Grep branch reads pattern with double quotes"
else
log_fail "BUG-RUN-004: Grep branch reads pattern with double quotes" \
"expected double-quoted .get(\"pattern\", \"\")"
fi

((TOTAL++))
if grep -qE "tool_input\.get\('pattern'" "$RUN_SH"; then
log_fail "BUG-RUN-004: no single-quoted 'pattern' literal in run.sh" \
"single-quoted literal reintroduced -- breaks bash SQ in python3 -u -c"
else
log_pass "BUG-RUN-004: no single-quoted 'pattern' literal in run.sh"
fi

# -------------------------------------------
# Syntax validation
# -------------------------------------------
((TOTAL++))
if bash -n "$LOKI" 2>/dev/null; then
log_pass "bash -n syntax validation passes"
log_pass "bash -n syntax validation passes (loki)"
else
log_fail "bash -n syntax validation (loki)" "script has syntax errors"
fi

((TOTAL++))
if bash -n "$RUN_SH" 2>/dev/null; then
log_pass "bash -n syntax validation passes (run.sh)"
else
log_fail "bash -n syntax validation" "script has syntax errors"
log_fail "bash -n syntax validation (run.sh)" "script has syntax errors"
fi

# -------------------------------------------
Expand Down
Loading