fix(webhook-modal): on copy do not change webhook url, fix auth to use regular perms system#812
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR addresses two distinct bugs in the webhook system:
-
Webhook URL Regeneration Bug: The webhook modal was generating new URLs on every re-render, particularly when users clicked the copy button. This was caused by the
formattedPathcomputation being executed directly in the component body, triggeringcrypto.randomUUID()on each render cycle. The fix usesuseMemoto memoize the path computation, ensuring the UUID is only generated once when the component mounts and remains stable across re-renders. -
Authentication System Enhancement: The webhook API endpoints (
/api/webhooks/[id]/route.tsand/api/webhooks/route.ts) were using basic ownership checking that only verified if a user owned a workflow directly. This missed cases where users have workspace-level permissions to access workflows they don't own. The fix integrates the proper permissions system usinggetUserEntityPermissionsto check workspace permissions, allowing users with appropriate workspace access (read for viewing, write/admin for modifications) to manage webhooks.
These changes align the webhook system with the established workspace permission model used throughout the codebase, ensuring consistent access control and fixing the UI bug that was causing user confusion with changing webhook URLs.
Confidence score: 4/5
• This PR safely fixes two well-defined bugs with targeted, minimal changes that don't introduce breaking changes
• The confidence score reflects that while the changes are solid, the authentication changes involve permission logic that should be thoroughly tested in multi-user scenarios
• Files requiring more attention: apps/sim/app/api/webhooks/[id]/route.ts and apps/sim/app/api/webhooks/route.ts for the new permission checking logic
3 files reviewed, no comments
…e regular perms system (simstudioai#812) * fix(webhook-modal): don't regenerate webhook url on copy * fix authentication checks for webhook saves
Description
Type of change
How Has This Been Tested?
Open up webhook modal -- and click on copy url button - should not generate a new URL each time.
Checklist:
bun run test)Security Considerations: