MiniMax M3 · 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
- 2 of 9
- Comments published
- 7
- Comments matching a bug
- 2
- Comments not matching
- 5
- Cost of this PR
- $0.262
Published comments (7)
parseRefreshTokenResponse overwrites missing refresh_token with literal string — In credential-sync mode the schema strips `refresh_token`, so the guard always writes the literal `"refresh_token"` to `Credential.key`. Subsequent Google and Microsoft refreshes then return `invalid_grant`.
refreshOAuthTokens returns raw fetch Response on sync branch without parsing — Callers like `googlecalendar`, `hubspot`, `larkcalendar`, `zoho-bigin`, and `zohocrm` read `.data`/`.access_token` off the raw `Response` and throw. Await `.json()` and return `{ data }` so the sync branch matches the legacy shape. **Also found in:** - `packages/app-store/_utils/oauth/refreshOAuthTokens.ts:1-20`
refreshOAuthTokens raw fetch Response breaks callers — Callers in `googlecalendar`, `zoomvideo`, and `office365calendar` read `.data`/`.access_token` from the raw `Response`, throwing on `token.access_token`. Await `.json()` (or reshape to the `{ res, tokens }` shape) so `parseRefreshTokenResponse` gets a parsed body.
statusText check fails on HTTP/2 responses — Salesforce serves over HTTP/2 where reason phrases arrive empty, so `response.statusText !== "OK"` rejects legitimate 200 responses with a spurious `HttpError`. Use `response.ok` (or a numeric status range) instead.
zoho-bigin passes credentialId where refreshOAuthTokens expects userId — `refreshOAuthTokens` posts its third arg as `calcomUserId`, but this caller passes `credential.id` (`credentialId`) instead of `credential.userId`. Pass `credential.userId` so the sync endpoint receives the user identifier it expects.
Webhook secret compared with non-constant-time equality — An attacker can recover the secret through timing because `!==` short-circuits on the first differing byte. Replace it with `crypto.timingSafeEqual` after the lengths match.
Race condition in credential findFirst/create creates duplicate Credential rows — Two concurrent webhook deliveries can both miss the `findFirst` and call `prisma.credential.create`, producing duplicate Credential rows. Wrap the pair in `prisma.$transaction` or use `prisma.credential.upsert` keyed on `userId`+`appId`.