Skip to content
Merged
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
20 changes: 15 additions & 5 deletions .claude/skills/triage-issue/scripts/write_job_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
Usage:
python3 write_job_summary.py <path-to-claude-execution-output.json>

Handles single JSON object or NDJSON (one JSON object per line).
Uses the last object with type "result" when multiple are present.
The execution file is written by anthropics/claude-code-action as a single
JSON array of messages (JSON.stringify(messages, null, 2)) at
$RUNNER_TEMP/claude-execution-output.json. We also support NDJSON (one
object per line). Uses the last object with type "result" for metrics.

Job summary has a ~1MB limit; raw JSON is truncated if needed to avoid job abort.
"""
Expand Down Expand Up @@ -52,17 +54,25 @@ def main() -> int:
continue
try:
obj = json.loads(line)
if obj.get("type") == "result":
if isinstance(obj, dict) and obj.get("type") == "result":
results.append(obj)
elif isinstance(obj, list):
for item in obj:
if isinstance(item, dict) and item.get("type") == "result":
results.append(item)
except json.JSONDecodeError:
continue

if not results:
# Try parsing whole content as single JSON
# Try parsing whole content as single JSON (object or array)
try:
obj = json.loads(content)
if obj.get("type") == "result":
if isinstance(obj, dict) and obj.get("type") == "result":
results = [obj]
elif isinstance(obj, list):
for item in obj:
if isinstance(item, dict) and item.get("type") == "result":
results.append(item)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No regression test added

Low Severity

This change fixes JSON parsing in write_job_summary.py, but the PR doesn’t add any unit/integration coverage to prevent regressions (e.g., a pretty-printed JSON array file and an NDJSON file). This was flagged because the review guidelines call out adding tests for fix PRs.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

except json.JSONDecodeError:
pass

Expand Down
Loading