fix: changed upper bound to be able to be null so it can be set blank…#167
Conversation
… and db:generation time
There was a problem hiding this comment.
Code Review
This pull request modifies the database schema to make the upper_bound_idx column nullable. However, the review feedback points out that corresponding backend changes are required to support this, including updating DTO validation, service type definitions, and adjusting nullish coalescing logic to handle explicit null values correctly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| profile: integer("profile").references(() => profiles.id), // associated profile | ||
| lower_bound_idx: integer("lower_bound_idx").notNull().default(0), // inclusive trim start index (default: 0) | ||
| upper_bound_idx: integer("upper_bound_idx").notNull(), // inclusive trim end index (set by service layer to length-1) | ||
| upper_bound_idx: integer("upper_bound_idx"), // inclusive trim end index (set by service layer to length-1) |
There was a problem hiding this comment.
While making upper_bound_idx nullable in the database schema is necessary to allow it to be set to blank, the current backend implementation will prevent this from working as expected:
- DTO Validation Failure: In
apps/backend/src/runs/dto/update-run.dto.ts,upper_bound_idxis decorated with@IsInt()and@Min(0). If a client sendsnull, validation will fail with a400 Bad Request. You should update the DTO to allow null, for example:@IsOptional() @IsInt() @Min(0) @ValidateIf((object, value) => value !== null) upper_bound_idx?: number | null;
- Service Type Mismatch: In
RunsService(runs.service.ts), theupdatesparameter type forupdateRunanddataforcreateRundefineupper_bound_idx?: number, which does not permitnull. These should be updated tonumber | null. - Nullish Coalescing Logic: In
RunsService.updateRun, the line:uses the nullish coalescing operator (const effectiveUpperBound = updates.upper_bound_idx ?? currentRun.upper_bound_idx ?? Math.max(effectiveLength - 1, 0);
??). Ifupdates.upper_bound_idxis passed asnullto clear the bound,updates.upper_bound_idx ?? ...will fall back tocurrentRun.upper_bound_idx(the old non-null value), preventing the field from ever being cleared/set tonullin the database. You will need to adjust this logic to distinguish betweenundefined(no update) andnull(explicitly clearing the bound).
… and db:generation time