Skip to content

Validate destination heat existence before advancing riders#67

Merged
danbim merged 3 commits into
neverthrowfrom
copilot/sub-pr-62-yet-again
Feb 4, 2026
Merged

Validate destination heat existence before advancing riders#67
danbim merged 3 commits into
neverthrowfrom
copilot/sub-pr-62-yet-again

Conversation

Copilot AI commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Addresses code review feedback from #62 requesting explicit validation of destination heats before advancing riders. Previously, addRiderToHeat silently returned when a destination heat didn't exist, masking potential data corruption bugs.

Changes

  • heat-service.ts: Extract validateAndAddRiderToHeat() private method that checks destination heat exists via getHeatByHeatId() before calling addRiderToHeat(). Returns err(HeatDoesNotExistError) on missing heat.

  • bracket-service.ts: Modify completeByeHeat() to return Result<void, HeatDoesNotExistError>, add destination heat validation, propagate errors to caller. Add HeatDoesNotExistError to BracketServiceError union.

Example

// Before: Silent failure if destination missing
if (metadata?.winnerDestinationHeatId) {
  await this.heatRepository.addRiderToHeat(metadata.winnerDestinationHeatId, winner.riderId);
}

// After: Explicit validation with typed error
if (metadata?.winnerDestinationHeatId) {
  const result = await this.validateAndAddRiderToHeat(
    metadata.winnerDestinationHeatId,
    winner.riderId
  );
  if (result.isErr()) {
    return err(result.error);
  }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update error handling to use Result types instead of exceptions Validate destination heat existence before advancing riders Feb 3, 2026
Copilot AI requested a review from danbim February 3, 2026 09:54
@danbim danbim marked this pull request as ready for review February 4, 2026 08:43
@danbim danbim merged commit e285102 into neverthrow Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants