Skip to content

fix: round-robin dispatch panics with more than 8 providers#61

Merged
javi11 merged 1 commit intomainfrom
fix/round-robin-panic-more-than-8-providers
Apr 8, 2026
Merged

fix: round-robin dispatch panics with more than 8 providers#61
javi11 merged 1 commit intomainfrom
fix/round-robin-panic-more-than-8-providers

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented Apr 8, 2026

Summary

  • Replaces the hard-coded [8]int cumulative-weights array in doSendWithRetry with a dynamically-sized make([]int, n) slice
  • Removes the now-unnecessary [:n] slice expression on the sort.SearchInts call
  • Adds TestClient_RoundRobinMoreThan8Providers to prevent regression

Root cause

// before
var cumWeights [8]int  // panics when len(mains) > 8
cumWeights[i] = totalW // index out of range [8] with length 8

Any deployment with 9+ main providers hit an immediate runtime error: index out of range panic.

Test plan

  • go test -run TestClient_RoundRobinMoreThan8Providers -race ./... passes
  • Full test suite passes

…patch

The weighted round-robin cumulative weights array was hard-coded to size 8,
causing an index-out-of-range panic when more than 8 main providers were
configured. Replace with make([]int, n) sized to the actual provider count.

Adds a regression test with 9 providers to prevent recurrence.
@javi11 javi11 merged commit 71c6154 into main Apr 8, 2026
1 check passed
@javi11 javi11 deleted the fix/round-robin-panic-more-than-8-providers branch April 8, 2026 08:08
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.

1 participant