Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .agents/scripts/supervisor/pulse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ cmd_pulse() {

local pr_state pr_merged_at
pr_state=$(echo "$pr_json" | grep -o '"state":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4 || true)
Comment on lines 590 to +591
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While adding || true effectively prevents the script from crashing, using grep and cut to parse JSON is inherently fragile. A more robust and maintainable approach is to use a dedicated JSON parser like jq, which is also mentioned as an alternative in the task description for t1071.

Using jq would make the code cleaner and safer, and would also address the same potential fragility in the pr_state extraction on the preceding line.

Suggested change
pr_state=$(echo "$pr_json" | grep -o '"state":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4)
pr_merged_at=$(echo "$pr_json" | grep -o '"mergedAt":"[^"]*"' | cut -d'"' -f4 || true)
pr_state=$(echo "$pr_json" | jq -r '.state')
pr_merged_at=$(echo "$pr_json" | jq -r '.mergedAt // empty')


if [[ "$pr_state" == "MERGED" ]]; then
local escaped_stale_id
Expand Down