Code Review Bench PR #25771 - feat: update recording, transcript endpoint and add tests#15
Conversation
| }) | ||
| async getBookingRecordings(@Param("bookingUid") bookingUid: string): Promise<GetBookingRecordingsOutput> { | ||
| const recordings = await this.calVideoService.getRecordings(bookingUid); | ||
| const recordings = this.calVideoService.getRecordings(bookingUid); |
There was a problem hiding this comment.
🚨 Bug: Missing await on async getRecordings() returns a Promise
CalVideoService.getRecordings() is an async method that returns Promise<RecordingItem[]> (it internally awaits database queries and Promise.all). The await was removed from the call in the controller, so recordings is now a Promise object, not the resolved array.
The return type annotation says Promise<GetBookingRecordingsOutput> with data: RecordingItem[], but the actual data field will contain an unresolved Promise. This will result in the API returning "data": {} (a serialized Promise object) instead of the actual recordings array, effectively breaking the recordings endpoint for all callers.
The test mocks this with mockResolvedValue([]) which returns a Promise — and since the handler is async, the returned object's data field will be a Promise that NestJS may or may not auto-resolve depending on serialization timing, but TypeScript's type system is being circumvented here.
Was this helpful? React with 👍 / 👎
| const recordings = this.calVideoService.getRecordings(bookingUid); | |
| const recordings = await this.calVideoService.getRecordings(bookingUid); |
- Apply suggested fix
| @Permissions([BOOKING_READ]) | ||
| @UseGuards(BookingUidGuard) | ||
| // @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) | ||
| @UseGuards(BookingPbacGuard, ApiAuthGuard, BookingUidGuard) |
There was a problem hiding this comment.
⚠️ Security: Guard order on transcripts puts PBAC before authentication
The transcripts endpoint uses @UseGuards(BookingPbacGuard, ApiAuthGuard, BookingUidGuard), which places BookingPbacGuard before ApiAuthGuard. NestJS executes guards in the order they are listed. This means the PBAC guard — which checks whether the authenticated user has access to the booking — will run before the user is even authenticated.
Every other endpoint in this controller that uses these three guards uses the order ApiAuthGuard, BookingUidGuard, BookingPbacGuard (authenticate → validate UID → check authorization). The recordings endpoint on line 217 uses this correct order. The transcripts endpoint should match.
Depending on the BookingPbacGuard implementation, this could either:
- Crash/throw when trying to access the user context (which hasn't been set yet)
- Or accidentally allow unauthenticated access if the guard fails open when no user is present
Was this helpful? React with 👍 / 👎
| @UseGuards(BookingPbacGuard, ApiAuthGuard, BookingUidGuard) | |
| @UseGuards(ApiAuthGuard, BookingUidGuard, BookingPbacGuard) |
- Apply suggested fix
There was a problem hiding this comment.
Configure merge blocking · Maintainers can dismiss this review. Gitar never approves changes.
Code Review 🚫 Blocked 0 resolved / 3 findingsSecurity hardening intent is good, but the recordings endpoint has a critical missing 🚨 Bug: Missing
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Benchmark PR for Gitar evaluation
Original PR: agentic-review-benchmarks#16
feat: update recording, transcript endpoint and add tests
Summary by Gitar
ApiAuthGuard,BookingUidGuard,BookingPbacGuard) for recordings and transcripts endpointsBOOKING_READtoBOOKING_WRITEfor elevated access controlThis will update automatically on new commits.