feat(linear): expose agent webhook triggers#126
Conversation
|
Warning Review limit reached
More reviews will be available in 11 minutes and 26 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for Linear agent webhook events, including AgentSessionEvent, AppUserNotification, PermissionChange, and OAuthApp. It updates the trigger catalog, webhook normalizer, path mapper, and the Linear adapter to process these events, and adds comprehensive unit tests. The review feedback highlights a potential file/directory conflict in linearAgentWebhookEventPath when objectId is missing, suggesting it should return null instead of the directory root, along with a corresponding test update.
| export function linearAgentWebhookEventPath(eventType: string, objectId?: string | null): string | null { | ||
| if (!LINEAR_AGENT_WEBHOOK_EVENTS.includes(eventType as (typeof LINEAR_AGENT_WEBHOOK_EVENTS)[number])) { | ||
| return null; | ||
| } | ||
| const category = linearAgentWebhookCategory(eventType); | ||
| if (!category) { | ||
| return null; | ||
| } | ||
| const root = LINEAR_AGENT_WEBHOOK_PATH_ROOTS[category]; | ||
| const id = objectId?.trim(); | ||
| return id ? `${root}/${encodeLinearPathSegment(id)}.json` : root; | ||
| } |
There was a problem hiding this comment.
Returning the directory root (root) when objectId is missing or empty can lead to file/directory conflicts in the virtual file system (VFS) or physical file system. Since other events under the same category will write to paths like ${root}/${id}.json, writing directly to ${root} as a file will fail or prevent subsequent writes to files within that directory.
Instead, we should require a non-empty objectId and return null if it is missing or empty.
| export function linearAgentWebhookEventPath(eventType: string, objectId?: string | null): string | null { | |
| if (!LINEAR_AGENT_WEBHOOK_EVENTS.includes(eventType as (typeof LINEAR_AGENT_WEBHOOK_EVENTS)[number])) { | |
| return null; | |
| } | |
| const category = linearAgentWebhookCategory(eventType); | |
| if (!category) { | |
| return null; | |
| } | |
| const root = LINEAR_AGENT_WEBHOOK_PATH_ROOTS[category]; | |
| const id = objectId?.trim(); | |
| return id ? `${root}/${encodeLinearPathSegment(id)}.json` : root; | |
| } | |
| export function linearAgentWebhookEventPath(eventType: string, objectId?: string | null): string | null { | |
| if (!LINEAR_AGENT_WEBHOOK_EVENTS.includes(eventType as (typeof LINEAR_AGENT_WEBHOOK_EVENTS)[number])) { | |
| return null; | |
| } | |
| const category = linearAgentWebhookCategory(eventType); | |
| if (!category) { | |
| return null; | |
| } | |
| const root = LINEAR_AGENT_WEBHOOK_PATH_ROOTS[category]; | |
| const id = objectId?.trim(); | |
| return id ? `${root}/${encodeLinearPathSegment(id)}.json` : null; | |
| } |
There was a problem hiding this comment.
Fixed in c134855: linearAgentWebhookEventPath now returns null when objectId is missing or empty, avoiding root file/directory conflicts.
| linearAgentWebhookEventPath('OAuthApp.revoked', 'oauth_client_123'), | ||
| '/linear/oauth-app/oauth_client_123.json', | ||
| ); | ||
| assert.equal(linearAgentWebhookEventPath('OAuthApp.revoked'), '/linear/oauth-app'); |
There was a problem hiding this comment.
Update the test to assert that linearAgentWebhookEventPath returns null when objectId is missing, to align with the safety improvement.
| assert.equal(linearAgentWebhookEventPath('OAuthApp.revoked'), '/linear/oauth-app'); | |
| assert.equal(linearAgentWebhookEventPath('OAuthApp.revoked'), null); |
There was a problem hiding this comment.
Fixed in c134855: updated the test expectation so OAuthApp.revoked without an object id returns null.
Summary
Validation
Follow-up