Skip to content

Fix MAX_OPEN_PRS gate failing with exit code 4 when no matching PRs exist#346

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-scheduled-max-open-prs-gate
Draft

Fix MAX_OPEN_PRS gate failing with exit code 4 when no matching PRs exist#346
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-scheduled-max-open-prs-gate

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

gh pr list --search exits with code 4 when no results are found. Under bash -e, this aborts the pre_activation step before COUNT is even assigned — causing every scheduled run to fail on repos where none of the agent's PRs are open.

Changes

  • 5 workflow templates (adhoc-qa, efficiency-improver, glossary-maintainer, perf-improver, test-improver): add 2>/dev/null || echo 0 fallback to the gh pr list command substitution
- COUNT=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --search 'in:title "[efficiency-improver]"' --json number --jq 'length')
+ COUNT=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --search 'in:title "[efficiency-improver]"' --json number --jq 'length' 2>/dev/null || echo 0)

Zero matching PRs is exactly the case where the workflow should run — this restores that invariant.

…xist

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix exit code 4 in scheduled MAX_OPEN_PRS gate Fix MAX_OPEN_PRS gate failing with exit code 4 when no matching PRs exist May 29, 2026
Copilot AI requested a review from pelikhan May 29, 2026 14:52
@pelikhan
Copy link
Copy Markdown
Contributor

@copilot recompile with latest release of gh aw

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 29, 2026

@copilot recompile with latest release of gh aw

Unable to upgrade gh aw in this environment — the releases API for github/gh-aw returns HTTP 403 due to SAML enforcement on the org, so both gh extension upgrade and gh extension install fail. The extension was previously at v0.66.1 but was removed during the upgrade attempt and cannot be reinstalled with the available token.

Could you run make compile locally with the latest gh aw release and share the output, or let me know if there are specific schema errors I should fix? I'm happy to address any compilation issues directly in the workflow files.

@pelikhan
Copy link
Copy Markdown
Contributor

@copilot revert lock files

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 29, 2026

@copilot revert lock files

Done — reverted the 4 lock files in bc69edd back to their pre-PR state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduled MAX_OPEN_PRS gate in 5 workflow templates fails with exit code 4 when no matching PRs exist

2 participants