Gemini 3.8 Flash · Balanced
oauth-credential-sync-and-app-integration-enhancements-cal-com
cal.com · TypeScript · M · 100–299 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 2 of 9
- Comments published
- 5
- Comments matching a bug
- 2
- Comments not matching
- 3
- Cost of this PR
- $0.581
Published comments (5)
Zod safe-parse wrapper stored in credential key — Subsequent reads parsing `credential.key` with `googleCredentialSchema` will throw validation errors because the `{ success: true, data: ... }` wrapper is saved instead of the payload. Pass `key.data` instead of `key` to `prisma.credential.update`.
Credential ID passed to refreshOAuthTokens instead of user ID — The sync service associates token refreshes with the wrong account or fails resolution because `credentialId` is forwarded as `calcomUserId`. Pass `credential.userId` instead, or update `refreshAccessToken` to receive and forward the user ID.
Raw fetch Response breaks callers expecting Axios data or token payload — Callers accessing `.data` on the returned `Response` receive `undefined` and throw a `TypeError` when credential sync is enabled. Parse and return the JSON payload from `response` instead of returning the raw Fetch `Response`.
Case-sensitive header lookup and non-constant-time secret comparison — Node.js lowercases all `req.headers` keys, causing mixed-case lookups to fail, while `!==` leaves the secret vulnerable to timing attacks. Convert `CALCOM_WEBHOOK_HEADER_NAME` to lowercase before indexing and compare the secret using `crypto.timingSafeEqual`.
Using `z.string().toString()` produces `[object Object]` schema keys — This strips token response properties other than `access_token` and skips expiry validation because `z.string().toString()` evaluates to the literal key `"[object Object]"`. Replace the computed keys with `z.record()` or chain `.passthrough()` on the schema.