GPT-6 Luna · 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
0 of 9
Comments published
5
Comments matching a bug
0
Comments not matching
5
Cost of this PR
$0.072

Published comments (5)

highbugpackages/app-store/_utils/oauth/refreshOAuthTokens.ts:8-15

Credential sync returns a response shape callers cannot consume — Callers may read an absent `data` property or treat the `Response` wrapper as token data when sync is enabled. Parse and normalize the endpoint response to the shape each caller expects.

mediumbugapps/web/pages/api/webhook/app-credential.ts:62-90

Concurrent webhook deliveries can create duplicate credentials — Concurrent deliveries can both create credentials for the same user and app, violating the one-credential-per-user/app invariant. Use an atomic upsert or add a unique constraint to the `Credential` schema.

mediumbugpackages/app-store/_utils/oauth/refreshOAuthTokens.ts:5

User ID 0 bypasses credential sync — A valid `userId` of `0` skips the sync path and uses the local provider refresh instead. Check explicitly for null or undefined so every valid ID uses the configured endpoint.

mediumsecurityapps/web/pages/api/webhook/app-credential.ts:24-27

Webhook secret comparison leaks matching prefixes through timing — Direct string comparison can leak matching secret prefixes through timing. Validate equal lengths, then compare the webhook secret with a constant-time function.

mediumsecurityapps/web/pages/api/webhook/app-credential.ts:56-59

Missing encryption key falls back to an empty string — Fail fast when `CALCOM_APP_CREDENTIAL_ENCRYPTION_KEY` is missing instead of attempting decryption.

Gold bugs found (0)

None.

Gold bugs missed (9)

mediumThe webhook parses the body with zod .parse and decrypts/JSON-parses the keys without error handling, so invalid payloads produce 500 errors instead of 400 responses.
highparseRefreshTokenResponse writes the hardcoded string 'refresh_token' when the refresh response omits a refresh token, so the stored credential gets an invalid refresh token and later refreshes fail.
mediumminimumTokenResponseSchema uses computed keys from z.string().toString(), which produce a literal key rather than a wildcard, so the sync-mode schema does not validate or keep expiry and other token fields as intended.
highGoogle Calendar persists the safeParse result object instead of its data as the credential key, corrupting the stored credential so later reads fail.
mediumSalesforce getClient now refreshes the OAuth token and writes the credential on every service construction, adding a network round trip and DB write even when the access token is valid.
highThe new Salesforce token refresh uses prisma without importing it, so the code fails type checking and throws a ReferenceError at runtime.
highSalesforce checks response.statusText !== 'OK' instead of response.ok when refreshing the token, which can misclassify successful responses, and then ignores the refreshed token.
highAfter refreshing the Salesforce token, jsforce.Connection is created with the stale access_token and instance_url instead of the newly refreshed values.
highThe app-credential webhook looks up appStoreMetadata by app.slug, but the map is keyed by dirName, so apps whose slug differs from their directory (e.g. google-calendar) always get a 404 and their credentials cannot be synced.