From 9d7139afe32f2a179b71527efae45af014601dd2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Apr 2026 07:02:05 +0000 Subject: [PATCH] fix: use jq for JSON-safe manifest writes in bug-report lifecycle step (#398) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid raw shell interpolation of multiline SUB_ISSUES into JSONL — titles with quotes/backslashes would produce invalid JSON. Co-Authored-By: Claude Opus 4.6 (1M context) --- formulas/run-gardener.toml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/formulas/run-gardener.toml b/formulas/run-gardener.toml index 3a88468..c3f9811 100644 --- a/formulas/run-gardener.toml +++ b/formulas/run-gardener.toml @@ -252,14 +252,21 @@ Sibling dependency rule (CRITICAL): '[.[] | select(.body != null) | select(.body | test("Decomposed from #" + ($n | tostring) + "\\b"))] | .[] | "- #\(.number) \(.title)"') - e. Write a comment action listing the resolved sub-issues: - echo '{"action":"comment","issue":N,"body":"All sub-issues have been resolved:\n'"$SUB_ISSUES"'\n\nClosing this parent issue as all decomposed work is complete."}' >> "$PROJECT_REPO_ROOT/gardener/pending-actions.jsonl" + e. Write a comment action listing the resolved sub-issues. + Use jq to build valid JSON (sub-issue titles may contain quotes/backslashes, + and SUB_ISSUES is multiline — raw interpolation would break JSONL): + COMMENT_BODY=$(printf 'All sub-issues have been resolved:\n%s\n\nClosing this parent issue as all decomposed work is complete.' "$SUB_ISSUES") + jq -n --argjson issue N --arg body "$COMMENT_BODY" \ + '{action:"comment", issue: $issue, body: $body}' \ + >> "$PROJECT_REPO_ROOT/gardener/pending-actions.jsonl" f. Write a close action: - echo '{"action":"close","issue":N,"reason":"all sub-issues resolved"}' >> "$PROJECT_REPO_ROOT/gardener/pending-actions.jsonl" + jq -n --argjson issue N \ + '{action:"close", issue: $issue, reason: "all sub-issues resolved"}' \ + >> "$PROJECT_REPO_ROOT/gardener/pending-actions.jsonl" g. Log the action: - echo "ACTION: closed #N — all sub-issues resolved: $SUB_ISSUES" >> "$RESULT_FILE" + echo "ACTION: closed #N — all sub-issues resolved" >> "$RESULT_FILE" Edge cases: - Already closed parent: skipped (only open issues are processed)