Skip to content

preview-deploy.sh's default invocation always exits 2

Id: TD-PPagop-26080301 · Status: resolved · Filed: 2026-08-03 · Resolved: 2026-08-03 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/189

scripts/preview-deploy.sh’s own docstring and --help text describe its primary use as running with no arguments “from its own workspace clone”, and that is exactly how both prompts/implementer.md (line 320) and prompts/reviewer.md (line 164) invoke it: "$AGENT_OPS_ROOT/scripts/preview-deploy.sh" --wait 180. That invocation always exits 2, in any repo, on gh 2.96.0.

With no --repo and no --pr, the script first fills slug from gh repo view (since slug is empty), then builds:

gh pr view --json headRefOid,number --jq '...' --repo "$slug"

gh pr view refuses this: passing --repo without also naming a PR number, URL, or branch is rejected with argument required when using the --repo flag — gh cannot infer “the pull request for the current branch” once --repo overrides the ambient repository context that inference relies on. Reproduce directly:

$ gh pr view --json headRefOid,number --repo Poetic-Poems/agent-ops
argument required when using the --repo flag
$ gh pr view td/TD-PPagop-26080102 --json headRefOid,number --repo Poetic-Poems/agent-ops
{"headRefOid":"...","number":167}

test/preview-deploy.test.sh does not catch this because it mocks gh as a shell function rather than exercising the real CLI’s argument validation, so the mocked gh pr view --repo X variant with no PR/branch argument silently succeeds where the real binary refuses.

Found while reviewing PR #167 (TD-PPagop-26080102): step 6 of prompts/reviewer.md calls for running preview-deploy.sh --wait 180, and it exited 2 for a reason unrelated to the documented “no VERCEL_AUTOMATION_BYPASS_SECRET” case. Exit 2 is treated as “could not check, not a failure” by that same procedure, so this has been silently absorbed rather than surfaced — every Reviewer run gets an uninformative “could not check” instead of an actual preview verdict, regardless of whether the secret is configured.

Suggested fix: when slug was filled automatically (not passed via --repo) and pr and sha are both empty, resolve the PR number via a call that does not combine --repo with implicit branch inference — e.g. gh pr view --json headRefOid,number without --repo when slug came from the same repo gh repo view already reports (the common case), falling back to an explicit --repo only once a PR number is known some other way (e.g. via gh pr list --head "$(git branch --show-current)" --repo "$slug").