From 4b95d32a0cdfb13414b1f2ba1bd5d406e3fcae32 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 15 Mar 2026 12:49:22 +0000 Subject: [PATCH] fix: planner PR lookup filters by head.ref client-side MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codeberg head= query param is unreliable — filter with jq instead. --- planner/planner-agent.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/planner/planner-agent.sh b/planner/planner-agent.sh index ba8c6a8..2595e9f 100755 --- a/planner/planner-agent.sh +++ b/planner/planner-agent.sh @@ -120,8 +120,8 @@ Output ONLY the bullet list — no preamble, no markdown fences, no explanation. git push -f origin "$branch_name" --quiet 2>/dev/null || { log "ERROR: failed to push $branch_name"; git checkout "${PRIMARY_BRANCH}" 2>/dev/null; return 1; } git checkout "${PRIMARY_BRANCH}" 2>/dev/null - # Create or update PR - EXISTING_PR=$(codeberg_api GET "/pulls?state=open&head=${CODEBERG_REPO%%/*}:${branch_name}&limit=1" 2>/dev/null | jq -r '.[0].number // empty') + # Create or update PR (filter by head ref — Codeberg's head param is unreliable) + EXISTING_PR=$(codeberg_api GET "/pulls?state=open&limit=50" 2>/dev/null | jq -r --arg branch "$branch_name" '.[] | select(.head.ref == $branch) | .number' | head -1) if [ -z "$EXISTING_PR" ]; then PR_RESPONSE=$(codeberg_api POST "/pulls" "{\"title\":\"chore: planner rebuild STATE.md\",\"head\":\"${branch_name}\",\"base\":\"${PRIMARY_BRANCH}\",\"body\":\"Automated STATE.md rebuild from git history + closed issues.\"}" 2>/dev/null) PR_NUM=$(echo "$PR_RESPONSE" | jq -r '.number // empty')