Skip to content

Replace force-unwrap of colorGradient.id with explicit ValidationError#6

Closed
Copilot wants to merge 1 commit into
feat/dashboard-real-datafrom
copilot/sub-pr-4
Closed

Replace force-unwrap of colorGradient.id with explicit ValidationError#6
Copilot wants to merge 1 commit into
feat/dashboard-real-datafrom
copilot/sub-pr-4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

toDb() and toInsertCompanion() on Pocket were force-unwrapping colorGradient.id!, causing a crash if a non-persisted or fallback gradient (id == null) was ever used.

Changes

  • toDb() / toInsertCompanion(): Replace colorGradient.id! with an explicit null-check that throws ValidationError with a descriptive message
// Before
colorGradientId: colorGradient.id!,

// After
final gradientId = colorGradient.id;
if (gradientId == null) {
  throw ValidationError(
    'Cannot update pocket: the selected color gradient has not been saved to the database. '
    'Ensure a valid gradient is chosen before updating a pocket.',
    StackTrace.current,
  );
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] WIP on connecting dashboard with real data Replace force-unwrap of colorGradient.id with explicit ValidationError Mar 6, 2026
@willyishmael willyishmael marked this pull request as ready for review March 6, 2026 05:14
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