Skip to content

Conversation

@sofwar
Copy link
Contributor

@sofwar sofwar commented Sep 26, 2025

  • Add safety check to ensure findBy query returns results before accessing first element
  • Prevent potential runtime errors in edge cases with race conditions
  • Maintain consistent NotEnoughObjects exception handling
  • No breaking changes to existing API or behavior

This enhancement improves the robustness of the random method by adding a defensive check that verifies the actual query results, not just the count, before attempting to access the first element. This prevents potential runtime errors in scenarios where count() might indicate objects exist but the actual query returns no results.

@nikophil
Copy link
Member

nikophil commented Oct 2, 2025

totally legit,

thanks @sofwar

@nikophil nikophil merged commit b4b2ffe into zenstruck:2.x Oct 2, 2025
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants