Skip to content

Narrow submit_pull_request_review event enum to allowed-events config - #54362

Open
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-allowed-events-schema
Open

Narrow submit_pull_request_review event enum to allowed-events config#54362
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-allowed-events-schema

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

submit-pull-request-review.allowed-events was only enforced at runtime — the generated submit_pull_request_review MCP tool schema still advertised all three event values (APPROVE, REQUEST_CHANGES, COMMENT), letting the agent pick a disallowed event. Runtime correctly rejected it, but this got misclassified as prompt injection by threat detection and failed the workflow instead of just posting the review.

Compiler change

  • computePropertyInjections (pkg/workflow/safe_outputs_tools_generation.go) now narrows the event field's enum to the configured allowed-events list, following the same pattern already used for close_issue's state_reason injection.
  • No config → no injection, full three-value enum stays as-is.
  • Runtime enforcement in submit_pr_review.cjs is unchanged and remains as defense in depth.

No JS changes were required: the existing generic property_injections mechanism in generate_safe_outputs_tools.cjs (already used for close_issue) picks up the new injection automatically.

For example, with:

safe-outputs:
  submit-pull-request-review:
    allowed-events: [COMMENT]

the generated tool schema now has "event": {"enum": ["COMMENT"]} instead of ["APPROVE", "REQUEST_CHANGES", "COMMENT"], so the agent can no longer select an event that will inevitably be rejected.

Tests

  • Added cases in pkg/workflow/safe_outputs_tools_generation_test.go covering single/multiple allowed events and the no-config default (full enum retained).

Copilot AI and others added 2 commits August 20, 2026 22:11
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix allowed-events in PR review tool schema Narrow submit_pull_request_review event enum to allowed-events config Aug 20, 2026
Copilot AI requested a review from pelikhan August 20, 2026 22:12
@pelikhan
pelikhan marked this pull request as ready for review August 20, 2026 23:18
Copilot AI balanced review requested due to automatic review settings August 20, 2026 23:18
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer failed. Please review the logs for details.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by Ponytail Reviewer for #54362

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #54362 does not have the 'implementation' label and has only 56 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-20T00:00:00Z
review_event: REQUEST_CHANGES
top_themes:
  - schema generation trusts AllowedEvents without defensive validation
  - tests cover only happy paths for submit_pull_request_review property injection
files_reviewed:
  - pkg/workflow/safe_outputs_tools_generation.go
  - pkg/workflow/safe_outputs_tools_generation_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 12.3 AIC · ⌖ 6.83 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

REQUEST_CHANGES — the schema narrowing is headed in the right direction, but it still trusts AllowedEvents too much at generation time and the added tests miss the failure mode.

The blocking theme
  • computePropertyInjections now copies SubmitPullRequestReview.AllowedEvents straight into the generated schema without re-validating it.
  • That assumption only holds if every construction path for SafeOutputsConfig goes through parseSubmitPullRequestReviewConfig, but this package already has direct struct-based tests and helpers, so future callers can feed invalid values into code generation and emit an invalid or misleading schema.
  • The new tests only cover the happy path and empty config, so they would not catch that regression.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 12.3 AIC · ⌖ 6.83 AIC · ⊞ 7K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is correct and well-tested. Narrowing the event enum at schema generation time prevents the agent from selecting a disallowed review decision while keeping runtime enforcement as defense-in-depth. Tests cover single event, multiple events, and the no-config no-op case.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 14.3 AIC · ⌖ 8.78 AIC · ⊞ 5.7K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — approving with one minor suggestion.

📋 Key Themes & Highlights

Key Themes

  • Root cause fixed at the right layer: The event enum is now narrowed at schema-generation time so the agent can never select a disallowed event in the first place. Runtime enforcement remains as defense-in-depth. This is the correct fix — eliminating the impossible call, not just rejecting it later.
  • Established pattern followed: The implementation mirrors the existing close_issuestate_reason injection exactly, keeping the codebase consistent.
  • Test coverage is solid: Three cases cover single event, multiple events, and the no-config default. One gap: a nil-config test (see inline comment) would make the suite symmetric with close_issue.

Positive Highlights

  • ✅ Defense-in-depth preserved — runtime check in submit_pr_review.cjs untouched
  • ✅ No JS changes needed; the generic property_injections path picks up the new injection automatically
  • ✅ Description in the event schema field explains why the enum is narrowed, which helps agent introspection

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 24.1 AIC · ⌖ 9.95 AIC · ⊞ 7.8K
Comment /matt to run again


// TestComputePropertyInjectionsNoAllowedEventsSubmitPRReview verifies that no injection
// happens when allowed-events is not configured, so the static schema's full enum applies.
func TestComputePropertyInjectionsNoAllowedEventsSubmitPRReview(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The close_issue nil-config test (TestComputePropertyInjectionsNilCloseIssues) covers nil config explicitly — adding the same for submit_pull_request_review would mirror the pattern and document the nil contract.

💡 Suggested addition
func TestComputePropertyInjectionsNilSubmitPRReview(t *testing.T) {
    injections := computePropertyInjections(&SafeOutputsConfig{
        SubmitPullRequestReview: nil,
    })
    assert.NotContains(t, injections, "submit_pull_request_review")
}

Low-risk omission — the != nil guard already handles this — but the symmetry with close_issue tests makes the contract explicit.

@copilot please address this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Narrows generated PR-review tool schemas to configured review events.

Changes:

  • Injects configured allowed-events into the event enum.
  • Adds tests for single, multiple, and default event sets.
Show a summary per file
File Description
pkg/workflow/safe_outputs_tools_generation.go Generates the restricted event schema.
pkg/workflow/safe_outputs_tools_generation_test.go Tests event-enum generation.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +349 to +354
if safeOutputs.SubmitPullRequestReview != nil && len(safeOutputs.SubmitPullRequestReview.AllowedEvents) > 0 {
allowedEvents := safeOutputs.SubmitPullRequestReview.AllowedEvents
injections["submit_pull_request_review"] = map[string]any{
"event": map[string]any{
"type": "string",
"enum": allowedEvents,
@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Triage

Category: feature · Risk: low · Priority: low

Score: 44/100 (impact 18/50 + urgency 10/30 + quality 16/20)

Recommended action: batch_review
Batch: chore-refactor-small

Small schema-tightening change with tests, CI passing.

Automated triage — run 32432526976

Generated by 🔧 PR Triage Agent · auto · 63.7 AIC · ⌖ 4.49 AIC · ⊞ 8.3K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for PR #54362.

Run: https://github.com/github/gh-aw/actions/runs/32434686968

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 20.3 AIC · ⌖ 6.12 AIC · ⊞ 5.5K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge for PR #54362.

  • Unresolved review feedback is still blocking this PR:...

Addressed the blocking review feedback in commit bd76983958.

I updated schema generation so submit_pull_request_review.event is required when allowed-events excludes COMMENT, added targeted tests, and pushed the fix.

Copilot AI requested a review from gh-aw-bot August 21, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allowed-events should constrain the generated PR review tool schema

4 participants