Gemini 3.8 Flash · 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
- 3 of 9
- Comments published
- 8
- Comments matching a bug
- 3
- Comments not matching
- 5
- Cost of this PR
- $1.400
Published comments (8)
Hardcoded refresh token dummy string overwrites stored credentials — Merging this result overwrites and permanently corrupts valid OAuth refresh tokens in the database. Remove the fallback assignment so `refresh_token` is omitted when absent.
Credential key updated with SafeParseReturnType instead of parsed data — Storing the wrapper object in the database corrupts the credential record and breaks subsequent calendar operations. Destructure `data` from `parseRefreshTokenResponse` so only the parsed credential payload is passed to `prisma.credential.update`.
refreshOAuthTokens receives credential ID instead of user ID — Passing a credential record ID prevents the sync endpoint from locating the Cal.com user. Pass `credential.userId` to `refreshOAuthTokens` instead of `credentialId`.
Raw fetch Response returned instead of response data expected by callers — Returning a raw `Response` lacks the `.data` property expected by callers, causing unhandled `TypeError` exceptions when accessing tokens. Parse the response body with `await response.json()` before returning it.
Header lookup fails if CALCOM_WEBHOOK_HEADER_NAME has uppercase characters — Node normalizes incoming header names to lowercase, causing lookup failures if `CALCOM_WEBHOOK_HEADER_NAME` contains uppercase characters. Call `.toLowerCase()` on the header key before indexing `req.headers`.
Insecure fallback to empty string for encryption key — Decrypting with an empty string compromises security when the environment variable is unset. Reject the request early if `process.env.CALCOM_APP_CREDENTIAL_ENCRYPTION_KEY` is missing instead of falling back to `""`.
Invalid `[z.string().toString()]` key in Zod schema strips response properties — Evaluating `toString()` creates a static `"[object Object]"` key, causing Zod to strip token expiry fields from the response. Chain `.passthrough()` onto `minimumTokenResponseSchema` instead of defining computed schema keys.
Timing attack vulnerability in webhook secret comparison — Comparing secrets with `!==` leaks timing information that allows attackers to guess the secret token. Use `crypto.timingSafeEqual` for a constant-time comparison instead.