framework tools/git: pr-review validates --action before provider contact (codex blocker on PR #1464)
ci/woodpecker/pr/ci Pipeline was canceled

An unsupported --action previously reached platform detection (and
could touch the provider) before failing with a provider-class status;
comment-without-body exited 1 mid-switch. Both now fail fast with
usage_error (rc 2, stderr) immediately after argument parsing. Test
arms added including the zero-provider-contact assertion for
invalid-action runs.
This commit is contained in:
2026-08-28 18:14:57 -05:00
parent e15e7fe822
commit da4a5b2f19
2 changed files with 19 additions and 4 deletions
@@ -116,6 +116,14 @@ if [[ -z "$ACTION" ]]; then
usage_error "Action is required (-a/--action): approve, request-changes, comment"
fi
# Validate the action BEFORE any provider contact (codex review of PR #1464:
# an unsupported --action previously reached platform detection and could
# touch the provider before failing with a provider-class status).
case "$ACTION" in
approve|request-changes|comment) ;;
*) usage_error "unknown action '$ACTION': approve, request-changes, comment" ;;
esac
if [[ -n "$REPO_OVERRIDE" ]]; then
# An explicit --repo is the whole point of a reviewer worktree whose origin
# is nonstandard or missing (#867 convention, mirrored from pr-view.sh /
@@ -715,8 +723,7 @@ if [[ "$PLATFORM" == "github" ]]; then
echo "Added review comment to GitHub PR #$PR_NUMBER"
;;
*)
echo "Error: Unknown action: $ACTION"
exit 1
usage_error "unknown action: $ACTION"
;;
esac
elif [[ "$PLATFORM" == "gitea" ]]; then
@@ -809,8 +816,7 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
echo "Added and verified comment on Gitea PR #$PR_NUMBER (comment ID $comment_id)"
;;
*)
echo "Error: Unknown action: $ACTION"
exit 1
usage_error "unknown action: $ACTION"
;;
esac
else