Claude Opus 5.5 · Heavy
oauth-credential-sync-and-app-integration-enhancements-cal-com
cal.com · TypeScript · M · 100–299 lines · 6 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.
- Gold bugs found
- 4 of 9
- Comments published
- 7
- Comments matching a bug
- 4
- Comments not matching
- 3
- Cost of this PR
- $4.301
Published comments (7)
Missing refresh_token is replaced with a placeholder that overwrites the stored token — Microsoft and sync-endpoint responses normally omit `refresh_token`, so Office365 spreads this placeholder over `o365AuthCredentials` and overwrites the real token, breaking every later refresh. Leave the field unset instead of writing the literal `"refresh_token"`.
Refresh-token parse result object saved as credential key instead of its data — Saving the whole `SafeParseReturnType` from `parseRefreshTokenResponse` as `credential.key` corrupts the Google credential, so `key.access_token` and `key.refresh_token` later read as undefined. Check `success` first, then save only `.data`.
Credential sync returns raw fetch Response instead of provider token shape — In sync mode, callers that read `res.data.access_token` or `zohoCrmTokenInfo.data` get undefined from a raw fetch `Response`, so the token refresh crashes. Return the same shape each provider's `refreshFunction` returns, or have callers parse the `Response` JSON. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:86-96` - `packages/app-store/zoho-bigin/lib/CalendarService.ts:96-97` - `packages/app-store/zohocrm/lib/CalendarService.ts:204-217` - `packages/app-store/hubspot/lib/CalendarService.ts:177-191` - `packages/app-store/hubspot/lib/CalendarService.ts:177-189`
Credential ID passed to refreshOAuthTokens where a user ID is expected — With credential sharing on, the sync endpoint receives `credentialId` as `calcomUserId` and may return another user's tokens or none at all. Pass the credential's `userId` to `refreshOAuthTokens` instead.
Salesforce token refreshed and DB updated on every service construction — Every booking that touches Salesforce pays an extra network call and DB write, and can hit Salesforce rate limits. Have `getClient` refresh only when the token has expired, or let jsforce's built-in refresh handle it.
Connection is created with the stale access token instead of the refreshed one — `jsforce.Connection` still gets the pre-refresh `credentialKey.access_token`, so the new token is never used and the refresh round-trip is wasted. Pass `accessTokenParsed.data.access_token` and its `instance_url` to the connection.
Webhook secret check uses a non-constant-time comparison — An attacker can time the `!==` check to recover `CALCOM_WEBHOOK_SECRET` byte by byte, and that secret alone guards an endpoint that writes credentials for any `userId`. Ensure the header is a single string, then compare equal-length Buffers with `crypto.timingSafeEqual` (or compare hashes).