Amazon Ergo 1.0 · 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 Opus 5.5.
- Gold bugs found
- 8 of 19
- Comments published
- 9
- Comments matching a bug
- 8
- Comments not matching
- 1
- Cost of this PR
- $3.359
Published comments (9)
Credential-sharing mode returns raw fetch Response instead of parsed body — Provider callers break: `googlecalendar` dereferences `res.data.access_token`, `zoho-bigin`/`zohocrm` read `tokenInfo.data`, and `hubspot` persists the `Response`. Parse the sync response body into the shape each caller expects, or update every caller to consume its body.
Missing refresh tokens are replaced with an invalid placeholder — Sharing-mode responses omit `refresh_token`, so `office365calendar` and `zoom` overwrite the real token with an invalid placeholder and fail on the next refresh. Preserve the existing refresh token instead of inventing one.
Sharing-mode token schema strips expiry and provider fields — The computed keys in `minimumTokenResponseSchema` collide as ordinary string keys rather than forming a catchall, so Zod strips `expiry_date`, `expires_in`, `instance_url`, and other provider fields. Use `.passthrough()`/`.catchall()` or an explicit schema.
Bigin token refresh passes credential ID as Cal.com user ID — `refreshOAuthTokens` sends `credentialId` as `calcomUserId`, so the sync endpoint may refresh the wrong user's token or fail. Pass `credential.userId` instead.
Credential sync leaves the invalid flag set after updating keys — The update writes `key` without clearing `credential.invalid`, so `getCalendarsEvents` keeps filtering out the credential and the app stays disabled. Set `invalid: false` when syncing valid `keys`.
Refreshed Salesforce token is not used for the connection — `getClient` builds the `jsforce.Connection` from pre-refresh `credentialKey.access_token` and `credentialKey.instance_url`, so the refreshed token is never used and expired-token failures persist. Build the connection from `accessTokenParsed.data`.
Credential-sync request is unauthenticated — Anyone who can reach `CALCOM_CREDENTIAL_SYNC_ENDPOINT` can request third-party tokens for arbitrary `calcomUserId` values because the request has no authentication. Send a signed or authenticated request and verify it on the endpoint.
Credential sync uses incorrect Zoom app slug — The sync endpoint cannot match credentials stored under the registered `zoom` slug, so Zoom token refresh fails. Replace `zoomvideo` with `zoom` (see `packages/app-store/zoomvideo/_metadata.ts`).
Salesforce token refresh runs on every service instantiation — Gate the refresh on the stored token's expiry.