-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: detect webhook on correct id #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe code was updated to change the database query for finding a webhook, switching the lookup key from the Changes
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn config production Use ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| const webhook = await prisma.webhook.findUnique({ | ||
| where: { id: webhookId }, | ||
| where: { pId: webhookId }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Good fix! Using the correct ID field will resolve the webhook detection issue.
The change from id to pId aligns with the PR objective of fixing webhook detection. This ensures webhooks are correctly identified in the database using the proper unique identifier.
To ensure consistency across the codebase, let's verify other webhook-related endpoints are also using pId:
🏁 Script executed:
#!/bin/bash
# Find other places in the codebase where webhooks are being looked up
rg "webhook.*findUnique" --type ts -A 3 -B 3Length of output: 927
Standardize webhook lookups to use pId in all endpoints
The events endpoint still queries by id instead of pId. Update the lookup in pages/api/teams/[teamId]/webhooks/[id]/events.ts so it matches the callback handler.
• File: pages/api/teams/[teamId]/webhooks/[id]/events.ts
Change the findUniqueOrThrow where clause:
- const { pId } = await prisma.webhook.findUniqueOrThrow({
- where: { id: webhookId, teamId },
+ const { pId } = await prisma.webhook.findUniqueOrThrow({
+ where: { pId: webhookId, teamId },This ensures all webhook endpoints consistently use pId to identify webhooks.
🤖 Prompt for AI Agents
In pages/api/teams/[teamId]/webhooks/[id]/events.ts around the webhook lookup
using findUniqueOrThrow, update the where clause to use pId instead of id for
identifying webhooks. This change aligns with the callback handler and ensures
consistent webhook identification across all endpoints by querying with the
correct unique identifier field pId.
Summary by CodeRabbit