GPT-6.1 Sol · 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
- 5 of 9
- Comments published
- 9
- Comments matching a bug
- 5
- Comments not matching
- 4
- Cost of this PR
- $1.352
Published comments (9)
Metadata lookup by directory key rejects valid app slugs — Valid apps such as `google-calendar` and `zoom` are rejected because `appStoreMetadata` uses directory keys `googlecalendar` and `zoomvideo`. Find the entry by its `slug`, or select the app's `dirName` and use it as the key.
Synchronized OAuth refresh returns a Response instead of token data — Returning a Fetch `Response` from `refreshOAuthTokens` breaks callers expecting `.data` or direct token properties when synchronization is enabled. Decode the response and adapt it to each caller's expected shape, or normalize both branches and update the callers together.
Sync token schema strips expiry and provider-specific fields — The computed keys in `minimumTokenResponseSchema` are literal strings, so expiry fields are stripped, breaking consumers such as Zoom's `newTokens.expires_in` calculation. Define `expires_in` and `expiry_date` explicitly and preserve provider-specific fields.
Safe-parse result is persisted instead of Google credential fields — Persisting the safe-parse wrapper returned by `parseRefreshTokenResponse` prevents `googleCredentialSchema.parse(credential.key)` from loading the credential, even with synchronization disabled. Check `result.success`, throw `result.error` on failure, and persist `result.data` as `key`.
Zoho Bigin token refresh uses the credential ID as the user ID — Passing `credentialId` as `calcomUserId` requests tokens for the wrong principal or a nonexistent user. Thread `credential.userId` from `biginAuth` into this call, retaining `credentialId` for database updates.
Zoom token sync uses an unrecognized app slug — An endpoint resolving `appSlug` cannot find this integration because Zoom's metadata and installed credential use `zoom`, not `zoomvideo`; check `packages/app-store/zoomvideo/_metadata.ts`. Pass `zoom` instead of the directory name.
Undefined Prisma client breaks Salesforce client initialization — Salesforce client initialization fails because `prisma` is neither imported nor defined in this file. Import the client from `@calcom/prisma` before calling `prisma.credential.update`.
Salesforce token refresh bypasses external credential sharing — Credentials managed by an external platform cannot refresh through this direct `fetch` request when credential sharing and `CALCOM_CREDENTIAL_SYNC_ENDPOINT` are enabled. Route the operation through `refreshOAuthTokens` with the Salesforce slug and `credential.userId`.
Salesforce client refreshes tokens unconditionally but uses stale credentials — Every Salesforce service construction adds a token request and database update, yet the connection still uses the original `credentialKey` token. Refresh only when required and initialize the connection with the refreshed credentials.