Skip to content

fix(github-bot): preserve PR lifecycle webhook fields - #1007

Merged
ColeMurray merged 2 commits into
mainfrom
fix/github-pr-lifecycle-webhooks
Jul 15, 2026
Merged

fix(github-bot): preserve PR lifecycle webhook fields#1007
ColeMurray merged 2 commits into
mainfrom
fix/github-pr-lifecycle-webhooks

Conversation

@ColeMurray

@ColeMurray ColeMurray commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • normalize GitHub automation events from the preserved webhook payload instead of the stripped logging summary
  • keep bot dispatch behavior separate from lifecycle automation policy in the shared normalizer/catalog
  • add regression coverage proving closed/merged PR state, repository identity, branches, SHA, URL, and timestamps reach the control plane

Root cause

The webhook Worker received pull_request.closed, but the summary schema removed nested lifecycle fields before normalization. The resulting control-plane event lacked pullRequest.state, so lifecycle processing skipped the update.

Verification

  • npm test -w @open-inspect/github-bot
  • npm run typecheck -w @open-inspect/github-bot
  • Prettier and git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Improved control-plane forwarding for pull request webhook events by normalizing the forwarded payload using the parsed action data when available (falling back safely when not).
  • Tests
    • Updated the webhook test suite to mock control-plane calls and added coverage to verify the forwarded lifecycle fields (event type, repository/branch/label, and pull request metadata with timestamp parsing).

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 682325f7-caa4-4767-83d0-54af9b14fe2e

📥 Commits

Reviewing files that changed from the base of the PR and between e7566b9 and dd63708.

📒 Files selected for processing (1)
  • packages/github-bot/src/index.ts
💤 Files with no reviewable changes (1)
  • packages/github-bot/src/index.ts

📝 Walkthrough

Walkthrough

Webhook handling now forwards normalized lifecycle data from the parsed action payload to the control plane. Tests mock the control-plane request and verify forwarded fields for closed pull requests.

Changes

Webhook automation forwarding

Layer / File(s) Summary
Dispatch and forwarding behavior
packages/github-bot/src/index.ts
Normalization now uses available passthrough action data, falling back to an empty object.
Control-plane forwarding test coverage
packages/github-bot/test/webhook.test.ts
Webhook tests configure the control-plane mock and validate the URL, method, and lifecycle fields forwarded for a closed pull request.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving pull request lifecycle webhook fields in github-bot.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/github-pr-lifecycle-webhooks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

Comment thread packages/github-bot/src/index.ts Outdated

@open-inspect open-inspect 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.

Summary

PR #1007, fix(github-bot): preserve PR lifecycle webhook fields, by @ColeMurray changes 2 files (+64/-4). The change correctly normalizes automation events from the passthrough webhook payload so PR lifecycle fields are preserved, and classifies closed/synchronize as automation-only bot events.

Critical Issues

None.

Suggestions

None.

Nitpicks

None.

Positive Feedback

  • The regression test verifies the key lifecycle fields that previously disappeared, including PR state, merge/close timestamps, SHA, branches, URL, labels, and repository identity.
  • The forwarding path remains isolated from normal bot handling failures, preserving existing webhook behavior.
  • The automation_event_only skip reason makes lifecycle-only handling clearer in logs.

Questions

None.

Verdict

Approve.

Verification: npm test -w @open-inspect/github-bot passed all 128 tests, and npm run typecheck -w @open-inspect/github-bot succeeded.

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @open-inspect[bot], Action: pull_request

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/github-bot/test/webhook.test.ts (1)

236-307: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test verifies forwarding but not the new automation_event_only classification itself.

This test confirms the control-plane payload is forwarded correctly for a closed PR, but nothing here (or elsewhere in the diff) asserts that dispatchHandler actually returns outcome: "skipped" / skip_reason: "automation_event_only" for pull_request.closed, nor is there a companion case for pull_request.synchronize. Since classifying these actions as lifecycle-only is a stated PR objective, a direct assertion (e.g., via a log.info/wideEvent spy, or by inspecting response semantics if exposed) would close the coverage gap for the actual new logic in index.ts lines 256-261.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/github-bot/test/webhook.test.ts` around lines 236 - 307, Extend the
webhook tests around dispatchHandler to directly verify the
automation_event_only classification: assert that pull_request.closed produces
outcome "skipped" with skip_reason "automation_event_only", and add a companion
pull_request.synchronize case with the same classification. Use the existing
log.info, wideEvent, or exposed response semantics used by the implementation,
while preserving the current forwarding assertions for lifecycle payloads.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/github-bot/test/webhook.test.ts`:
- Around line 236-307: Extend the webhook tests around dispatchHandler to
directly verify the automation_event_only classification: assert that
pull_request.closed produces outcome "skipped" with skip_reason
"automation_event_only", and add a companion pull_request.synchronize case with
the same classification. Use the existing log.info, wideEvent, or exposed
response semantics used by the implementation, while preserving the current
forwarding assertions for lifecycle payloads.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 103b800f-85a5-4b39-9b7f-b68c980c7145

📥 Commits

Reviewing files that changed from the base of the PR and between 84fe1f7 and e7566b9.

📒 Files selected for processing (2)
  • packages/github-bot/src/index.ts
  • packages/github-bot/test/webhook.test.ts

@ColeMurray
ColeMurray merged commit 286a82b into main Jul 15, 2026
18 checks passed
@ColeMurray
ColeMurray deleted the fix/github-pr-lifecycle-webhooks branch July 15, 2026 07:13
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.

1 participant