Skip to content

fix(github-bot): run automation forwarding independently - #1519

Open
ColeMurray wants to merge 1 commit into
mainfrom
fix/github-webhook-parallel-forwarding
Open

fix(github-bot): run automation forwarding independently#1519
ColeMurray wants to merge 1 commit into
mainfrom
fix/github-webhook-parallel-forwarding

Conversation

@ColeMurray

@ColeMurray ColeMurray commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • start built-in GitHub dispatch and normalized automation forwarding together
  • settle both paths before applying the existing dispatch-failure cleanup policy
  • make the dispatcher async so synchronous schema failures cannot suppress forwarding
  • cover a deferred built-in dispatch with a regression test

Why

Follow-up to #1506. That change preserves forwarding after a dispatch rejection, but forwarding still did not begin until built-in dispatch settled. A slow or non-settling handler could therefore continue to block an otherwise independent automation event.

Testing

  • npm run build -w @open-inspect/shared
  • npm test -w @open-inspect/github-bot (131 tests)
  • npm run typecheck -w @open-inspect/github-bot
  • npm run lint -w @open-inspect/github-bot
  • npx prettier --check packages/github-bot/src/index.ts packages/github-bot/test/webhook.test.ts
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Improved webhook processing so GitHub event forwarding and built-in event handling run concurrently.
    • Dispatch errors are now reported consistently while event-forwarding failures are logged independently.
    • Unsupported event types are handled more cleanly without affecting other webhook processing.

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate
Tests

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

@coderabbitai

coderabbitai Bot commented Aug 19, 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 Plus

Run ID: 1a0647d7-0958-473a-9ea9-72f52de0b315

📥 Commits

Reviewing files that changed from the base of the PR and between c3af07b and e37fd47.

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

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

handleWebhook now runs GitHub event dispatch and automation forwarding concurrently. It logs each outcome independently, rethrows dispatch failures, and adds integration coverage for overlapping requests.

Changes

Webhook forwarding

Layer / File(s) Summary
Concurrent dispatch and forwarding
packages/github-bot/src/index.ts
handleWebhook uses Promise.allSettled for dispatch and forwarding. The forwarding helper skips unsupported events, normalizes payloads, and sends signed control-plane requests.
Concurrent forwarding integration test
packages/github-bot/test/webhook.test.ts
The test verifies that automation forwarding starts before built-in event dispatch completes and that failed deferred work is flushed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e37fd

The change runs built-in dispatch and automation forwarding independently while preserving existing cleanup behavior; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant handleWebhook
  participant GitHubEventDispatch
  participant forwardGitHubAutomationEvent
  participant ControlPlaneRequest
  handleWebhook->>GitHubEventDispatch: start built-in event dispatch
  handleWebhook->>forwardGitHubAutomationEvent: start automation forwarding
  forwardGitHubAutomationEvent->>ControlPlaneRequest: send signed normalized event
  GitHubEventDispatch-->>handleWebhook: return dispatch outcome
  ControlPlaneRequest-->>forwardGitHubAutomationEvent: return forwarding outcome
Loading

Possibly related PRs

Suggested reviewers: hydraxman, open-inspect

🚥 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 and concisely describes the main change: running automation forwarding independently during GitHub webhook handling.
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-webhook-parallel-forwarding

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.

@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 #1519, fix(github-bot): run automation forwarding independently by @ColeMurray changes GitHub webhook handling so built-in dispatch and automation-event forwarding start together and settle before dispatch-failure cleanup. Reviewed 2 files (+130/-60); the approach is focused and preserves existing forwarding failure isolation while fixing the delayed-forwarding behavior.

Critical Issues

None found.

Suggestions

None.

Nitpicks

None.

Positive Feedback

  • Making dispatchHandler async is a clean way to convert synchronous schema failures into a rejected promise, ensuring forwarding is still started.
  • Promise.allSettled keeps forwarding failures non-fatal while preserving the existing dispatch-failure dedupe cleanup behavior.
  • The regression test directly exercises the important ordering: forwarding begins while built-in dispatch is still pending.

Questions

None.

Verification

  • npm test -w @open-inspect/github-bot: 7 test files passed, 131 tests passed.
  • npm run typecheck -w @open-inspect/github-bot: passed.

Verdict

Approve: ready to merge.

let result: HandlerResult | undefined;
let dispatchFailure: { error: unknown } | undefined;
const normalizationPayload = actionResult.success ? actionResult.data : {};
const [dispatchResult, forwardingResult] = await Promise.allSettled([

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.

[deep review] This couples dispatch observability to the independent forwarding path. Because Promise.allSettled waits for both operations, webhook.handled is now delayed by a slow forward (or suppressed by a non-settling one), and duration_ms measures max(dispatch, forwarding) rather than built-in dispatch as it did before. There is a simpler code-judo move: start forwardGitHubAutomationEvent(...) and retain its promise before entering the existing try/await dispatchHandler flow, log dispatch as soon as that settles, then await/log forwarding before rethrowing any captured dispatch error. Starting forwarding first also means dispatchHandler does not need to become artificially async; its synchronous schema errors remain caught by the existing try. That preserves the cleanup policy while deleting the two settled-result state machines and retaining accurate telemetry.

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

[deep review] Requesting changes for the dispatch-observability regression noted inline. The two operations should start independently, but dispatch logging and timing should not wait on forwarding. Starting the forwarding promise first and then retaining the existing dispatch try/await flow preserves the intended cleanup behavior with substantially less orchestration.

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