From 697c5ec4722e89e15504f2a1370022ceea5f689e Mon Sep 17 00:00:00 2001 From: Sasa Junuzovic Date: Wed, 15 Apr 2026 07:11:17 -0700 Subject: [PATCH] fix: paginate orchestrator issue dispatch to find eligible issues (#928) The dispatch query used `first: 20` with no pagination, causing newer undispatched issues to be invisible when 20+ old handled issues filled the window. Now paginates through all pages (100 per page) until an eligible issue is found. Also added `backlog` to the label exclusion filter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pipeline-orchestrator.yml | 52 ++++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pipeline-orchestrator.yml b/.github/workflows/pipeline-orchestrator.yml index 32e44a92..aab7e26b 100644 --- a/.github/workflows/pipeline-orchestrator.yml +++ b/.github/workflows/pipeline-orchestrator.yml @@ -115,25 +115,53 @@ jobs: exit 0 fi - # Find oldest aw-labeled issue without aw-dispatched, agentic-workflows, or aw-protected-files - ISSUE=$(gh api graphql -f query=' - query($owner: String!, $repo: String!) { - repository(owner: $owner, name: $repo) { - issues(labels: ["aw"], states: OPEN, first: 20, orderBy: {field: CREATED_AT, direction: ASC}) { - nodes { - number - title - labels(first: 100) { nodes { name } } + # Find oldest aw-labeled issue without aw-dispatched, agentic-workflows, aw-protected-files, or backlog + CURSOR="" + ISSUE="null" + while true; do + if [[ -n "$CURSOR" ]]; then + CURSOR_ARG=", after: \"$CURSOR\"" + else + CURSOR_ARG="" + fi + + RESULT=$(gh api graphql -f query=" + query(\$owner: String!, \$repo: String!) { + repository(owner: \$owner, name: \$repo) { + issues(labels: [\"aw\"], states: OPEN, first: 100, orderBy: {field: CREATED_AT, direction: ASC}${CURSOR_ARG}) { + nodes { + number + title + labels(first: 100) { nodes { name } } + } + pageInfo { + hasNextPage + endCursor + } } } - } - }' -f owner="$OWNER" -f repo="$REPO" \ - --jq '[.data.repository.issues.nodes[] | select( + }" -f owner="$OWNER" -f repo="$REPO") + + ISSUE=$(echo "$RESULT" | jq '[.data.repository.issues.nodes[] | select( ([.labels.nodes[].name] | any(. == "aw-dispatched") | not) and ([.labels.nodes[].name] | any(. == "agentic-workflows") | not) and ([.labels.nodes[].name] | any(. == "aw-protected-files") | not) + and ([.labels.nodes[].name] | any(. == "backlog") | not) )] | .[0]') + # Found an eligible issue — stop paginating + if [[ "$ISSUE" != "null" && -n "$ISSUE" ]]; then + break + fi + + # Check if there are more pages + HAS_NEXT=$(echo "$RESULT" | jq -r '.data.repository.issues.pageInfo.hasNextPage') + if [[ "$HAS_NEXT" != "true" ]]; then + break + fi + CURSOR=$(echo "$RESULT" | jq -r '.data.repository.issues.pageInfo.endCursor') + done + if [[ "$ISSUE" == "null" || -z "$ISSUE" ]]; then echo "No eligible issues to dispatch. Pipeline idle." exit 0