Skip to content

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Nov 24, 2025

What does this PR do?

Fixes 500 error ("Internal Error: Weight filter should never return length=0.") in round-robin scheduling caused by

  1. Division by zero in OOO calibration: When a single host has out-of-office entries, the calibration calculation bookingsInTimeframe.length / (hosts.length - 1) causes division by zero

This issues causes NaN to propagate through booking shortfall calculations, resulting in Math.max(...NaN values) = NaN, and the filter user.bookingShortfall === NaN returns an empty array (since NaN !== NaN), triggering the error "Internal Error: Weight filter should never return length=0."

Solutions implemented:

  1. OOO calibration guard: Skip OOO calibration when hosts.length <= 1 (conceptually meaningless with a single host)

Mandatory Tasks

  • I have self-reviewed the code
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change - N/A (internal bug fix, no API changes)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link

vercel bot commented Nov 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Nov 25, 2025 4:34am
cal-eu Ignored Ignored Nov 25, 2025 4:34am

@devin-ai-integration devin-ai-integration bot changed the title fix: handle zero weights in round-robin scheduling to prevent 500 errors fix: prevent 500 errors in round-robin scheduling from OOO calibration and zero weights Nov 25, 2025
@hbjORbj hbjORbj closed this Nov 25, 2025
@hbjORbj hbjORbj force-pushed the devin/fix-round-robin-zero-weights-1763989416 branch from 05c9bcc to f2b2b6e Compare November 25, 2025 04:31
@hbjORbj hbjORbj marked this pull request as ready for review November 25, 2025 04:34
@hbjORbj hbjORbj requested a review from a team as a code owner November 25, 2025 04:34
@hbjORbj hbjORbj changed the title fix: prevent 500 errors in round-robin scheduling from OOO calibration and zero weights fix: prevent 500 errors in round-robin scheduling from OOO calibration Nov 25, 2025
@hbjORbj hbjORbj changed the title fix: prevent 500 errors in round-robin scheduling from OOO calibration fix: prevent 500 errors in round-robin scheduling from OOO calibration for single host Nov 25, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@github-actions
Copy link
Contributor

E2E results are ready!

@hbjORbj hbjORbj enabled auto-merge (squash) November 25, 2025 05:47
@hbjORbj hbjORbj merged commit 272d97c into main Nov 25, 2025
65 of 66 checks passed
@hbjORbj hbjORbj deleted the devin/fix-round-robin-zero-weights-1763989416 branch November 25, 2025 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants