Repository navigation
Fix/candidate pool empty array - #3871
diegosouzapw merged 4 commits into
Conversation
expandAutoComboCandidatePool() returned early when candidatePool was an array, but an empty array meant the candidate pool stayed empty — no targets were ever broadened. Only return early when candidatePool has at least one entry.
There was a problem hiding this comment.
Code Review
This pull request modifies expandAutoComboCandidatePool to ensure that an empty candidatePool array does not trigger an early return, allowing the function to fall back to active connections. A corresponding unit test has been added to verify this behavior. The reviewer pointed out a potential TypeScript compiler error when accessing .length on an unknown type property and suggested extracting candidatePool to a local variable for proper type narrowing. Additionally, the reviewer identified a similar check on line 3264 that should be updated as well.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (Array.isArray(localAutoConfig?.candidatePool) && localAutoConfig.candidatePool.length > 0) | ||
| return eligibleTargets; |
There was a problem hiding this comment.
While this change correctly prevents an early return when candidatePool is an empty array, accessing localAutoConfig.candidatePool.length directly might trigger TypeScript compiler errors (e.g., Object is of type 'unknown' or Property 'length' does not exist on type 'unknown') because localAutoConfig is typed as Record<string, unknown>.
Extracting candidatePool to a local variable allows TypeScript's Array.isArray type guard to correctly narrow its type to any[], ensuring type-safe access to .length.
Additionally, please note that there is a similar check on line 3264:
const candidatePool = Array.isArray(autoConfigSource.candidatePool)
? autoConfigSource.candidatePool
: [...new Set(eligibleTargets.map((target) => target.provider))];If autoConfigSource.candidatePool is an empty array [], it will bypass the fallback and pass [] to selectAutoProvider, which will fail to select any candidates. You should also update line 3264 to check for length > 0 so it correctly falls back to the active connections' providers.
| if (Array.isArray(localAutoConfig?.candidatePool) && localAutoConfig.candidatePool.length > 0) | |
| return eligibleTargets; | |
| const candidatePool = localAutoConfig?.candidatePool; | |
| if (Array.isArray(candidatePool) && candidatePool.length > 0) | |
| return eligibleTargets; |
…ate-pool-empty-array
PR cheaper-inference#3871 own growth: combo.ts 5203->5204 (+1). Updates the frozen file-size baseline so Fast Quality Gates pass on release/v3.8.26. Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
|
Thanks, @YunyunZhai! 🙏 Sharp catch — |
Integrated into release/v3.8.26
Summary
Related Issues
Validation
npm run lintnpm run test:unitnpm run test:coverage>= 60%for statements, lines, functions, and branchesTests Added Or Updated
Coverage Notes
Reviewer Notes