Overview
The GitHub webhook endpoint receives per-repository webhook events from GitHub when pull requests are opened or updated. Nectr responds immediately (within GitHub’s 10-second timeout) and processes reviews asynchronously in the background.Nectr uses per-repository webhooks only. GitHub App integration events are not supported.
Endpoint
Security
All webhook payloads are verified using HMAC-SHA256 signatures. Nectr checks theX-Hub-Signature-256 header against the per-repository webhook secret stored in the database.
Signature Verification
The webhook secret is retrieved from the
Installation table for the repository. If not found, falls back to the global GITHUB_WEBHOOK_SECRET environment variable.HMAC-SHA256 Comparison
Computes
sha256=<hmac_hex> using the webhook secret and compares it against the provided signature using constant-time comparison.Headers
HMAC-SHA256 signature of the request body, prefixed with
sha256=Hook delivery type. Must be
repository. Events with value integration (GitHub App) are rejected.GitHub event type (e.g.,
pull_request, issues, push)Request Body
The request body is the standard GitHub webhook payload in JSON format. The exact schema depends on the event type.Pull Request Events
Response
The endpoint returns immediately with a200 OK status to avoid GitHub’s timeout.
One of:
received, duplicate_skipped, or ignoredDatabase ID of the created event (only when status is
received)Derived event type (e.g.,
opened_pull_request, synchronize_pull_request)Reason for ignoring or skipping the event
Additional details when event is duplicate
Event Processing Flow
Deduplication
Checks for pending/processing events for the same PR within the last hour to avoid duplicate reviews.
Background Processing
For PR events (
opened or synchronize actions), updates status to processing and queues a background task.Background Review Process
After responding to GitHub, Nectr processes the PR review asynchronously:- Fetch PR Data — Uses GitHub REST API to get diff, files, and file contents
- Pull MCP Context — Optionally fetches linked issues (Linear), errors (Sentry), and messages (Slack)
- Build Review Context — Queries Neo4j for file experts and related PRs; queries Mem0 for project patterns
- AI Analysis — Sends context to Claude Sonnet 4.6 for review (standard or parallel agent mode)
- Post Review — Posts the review as a GitHub comment using the user’s OAuth token
- Index in Neo4j — Creates PullRequest, Developer, and File nodes with relationships
- Extract Memories — Stores patterns and insights in Mem0 for future reviews
- Update Event Status — Marks event as
completedorfailed
Error Responses
HTTP status code
Error message
Webhook Configuration
When connecting a repository through Nectr’s UI, the webhook is automatically configured with:- Payload URL:
https://your-backend.up.railway.app/api/v1/webhooks/github - Content type:
application/json - Secret: Auto-generated and stored in the database
- Events:
Pull requestsonly - Active:
true
Supported Event Types
| Event Type | Actions | Behavior |
|---|---|---|
pull_request | opened, synchronize | Triggers AI review |
pull_request | Other actions | Logged, no review |
issues | All | Logged, no review |
push | All | Logged, no review |
Rate Limiting
Nectr implements automatic deduplication to prevent duplicate reviews:- Checks for existing
pendingorprocessingevents for the same PR - Scope: Last 1 hour
- Match criteria: Same PR number + same repository full name
- Result: Returns
200 OKwithduplicate_skippedstatus
Source Code
The webhook implementation is located at:verify_github_signature()— HMAC-SHA256 verification (line 24)process_pr_in_background()— Async review processor (line 41)github_webhook()— Main endpoint handler (line 96)