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.
1
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.2
HMAC-SHA256 Comparison
Computes
sha256=<hmac_hex> using the webhook secret and compares it against the provided signature using constant-time comparison.3
Rejection
Returns
403 Forbidden if the signature does not match (production only).Headers
string
required
HMAC-SHA256 signature of the request body, prefixed with
sha256=string
Hook delivery type. Must be
repository. Events with value integration (GitHub App) are rejected.string
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.
string
required
One of:
received, duplicate_skipped, or ignoredinteger
Database ID of the created event (only when status is
received)string
Derived event type (e.g.,
opened_pull_request, synchronize_pull_request)string
Reason for ignoring or skipping the event
string
Additional details when event is duplicate
Event Processing Flow
1
Signature Verification
Verifies the HMAC-SHA256 signature using the per-repo webhook secret.
2
Event Type Detection
Determines event type from payload structure (
pull_request, issue, push).3
Deduplication
Checks for pending/processing events for the same PR within the last hour to avoid duplicate reviews.
4
Event Creation
Creates an
Event record in the database with status pending.5
Background Processing
For PR events (
opened or synchronize actions), updates status to processing and queues a background task.6
Immediate Response
Returns HTTP 200 to GitHub within milliseconds.
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
number
required
HTTP status code
string
required
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
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)