gh-aw icon indicating copy to clipboard operation
gh-aw copied to clipboard

required-labels is silently ignored for reply-to-pull-request-review-comment and resolve-pull-request-review-thread

Open ekbritecore opened this issue 2 months ago • 0 comments

Title

required-labels is silently ignored for reply-to-pull-request-review-comment and resolve-pull-request-review-thread

Body

Analysis

required-labels: compiles with zero warnings for both reply-to-pull-request-review-comment and resolve-pull-request-review-thread, and the docs (safe-outputs-pull-requests reference) list it as a valid option for both, with the same semantics as every other safe-output that supports it (push-to-pull-request-branch, create-pull-request, etc: only act if the target PR carries all these labels). In practice it enforces nothing for these two types.

Confirmed by reading the source directly (not just observing compiled output): both config structs embed SafeOutputFilterConfig (which holds RequiredLabels), and the handler-registry codegen that builds the runtime tool config for both types already reads c.RequiredLabels via AddStringSlice("required_labels", c.RequiredLabels) (safe_outputs_handler_registry_pull_requests.go) -- so the plumbing downstream of parsing is correct and ready to receive the value.

The gap is upstream of that: neither type's own parser function actually reads required-labels out of the YAML config map at all.

  • parseReplyToPullRequestReviewCommentConfig (reply_to_pr_review_comment.go) parses target, target-repo, allowed-repos, and footer -- never required-labels.
  • parseResolvePullRequestReviewThreadConfig (resolve_pr_review_thread.go) only calls parseBaseSafeOutputConfig and ParseTargetConfig -- also never touches required-labels.

Compare to push_to_pull_request_branch.cjs's own parser, which calls ParseStringArrayOrExprFromConfig(configMap, "required-labels", ...) explicitly (falling back to labels for back-compat) -- the pattern these two are missing.

Why this matters

For safe-outputs whose target is "*" (agent supplies the PR/thread identifier per call, no automatic "triggering PR" scoping), required- labels is often the only thing constraining which PR a confused or steered agent can act against. comment_id (REST) and thread_id (GraphQL node ID) are both repo-global identifiers with no inherent tie to "the PR this workflow is supposed to be scoped to" -- without a working required-labels guard, nothing stops a call from referencing an ID that belongs to an entirely different PR in the same repo.

Reproduction

safe-outputs:
  reply-to-pull-request-review-comment:
    target: "*"
    required-labels: [automation, my-workflow]
  resolve-pull-request-review-thread:
    target: "*"
    required-labels: [automation, my-workflow]

Compiles with 0 warnings. Inspecting the compiled GH_AW_SAFE_OUTPUTS_CONFIG / GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG env vars in the generated lock file shows required_labels present for other safe-output types configured the same way in the same workflow, but absent entirely from these two types' own config blocks -- confirming the value never made it past parsing.

Implementation Plan

  1. In parseReplyToPullRequestReviewCommentConfig (reply_to_pr_review_comment.go), parse required-labels into config.RequiredLabels the same way push_to_pull_request_branch's parser does (ParseStringArrayOrExprFromConfig or the shared filter- config helper, if one exists for this purpose -- pkg/workflow/safe_outputs_parser.go's SafeOutputFilterConfig{} usage looked like a candidate but wasn't being invoked by either of these two parsers).
  2. Same fix in parseResolvePullRequestReviewThreadConfig (resolve_pr_review_thread.go).
  3. Add a test per type asserting required-labels in the source YAML actually appears in the compiled config's required_labels field, not just that compilation succeeds without error.

Acceptance Criteria

  • required-labels configured on reply-to-pull-request-review-comment or resolve-pull-request-review-thread shows up in the compiled required_labels field, matching the behavior of push-to-pull-request-branch configured the same way.
  • A workflow run attempting to reply/resolve against a PR missing one of the required labels is actually blocked at runtime, not just documented as blocked.

ekbritecore avatar Sep 22 '26 14:09 ekbritecore