DeepSeek V4 Pro · Heavy

feat-convert-insightsbookingservice-to-use-prisma-sql-raw-queries-cal-com

cal.com · TypeScript · M · 100–299 lines · 1 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
1 of 3
Comments published
2
Comments matching a bug
1
Comments not matching
1
Cost of this PR
$1.320

Published comments (2)

highbugpackages/lib/server/service/insightsBooking.ts:29-34

teamId is optional for team scope in public options type — A team-scope caller can now omit `teamId` and the lookup runs with `id: undefined`, silently returning `NOTHING_CONDITION` or matching the wrong team. Keep `teamId` required for the team scope, e.g. as a discriminated union, or handle the missing value in `buildTeamAuthorizationCondition`.

mediumbugpackages/lib/server/service/__tests__/insightsBooking.integration-test.ts:295-299

Prisma.sql deep-equality fails due to nested fragment construction — The service composes conditions with nested `Prisma.sql` fragments via `reduce`, so `toEqual` compares different internal `strings`/`values` arrays and the assertions fail—nested `Sql` fragments are only flattened at serialization time. Build the expected fragments with the same nested composition, or assert on the rendered `conditions.sql` instead. **Also found in:** - `packages/lib/server/service/__tests__/insightsBooking.integration-test.ts:429-431`

Gold bugs found (1)

mediumThe new public options type makes teamId optional for team scope, so a missing teamId compiles and silently yields empty insights instead of a type error.

Gold bugs missed (2)

mediumThe getBaseConditions test uses a single booking matching both auth and filter conditions, so it would pass even if the conditions were not combined.
highClaims getBaseConditions returns OR fragments without parentheses, so a caller appending `AND <extra>` would leak rows outside the authorization scope.