fix: fall through to OPENROUTER_API_KEY env var when credential pool is exhausted (#23452)#23903
Closed
LiWeny16 wants to merge 1 commit into
Closed
Conversation
This was referenced May 11, 2026
Closed
Collaborator
…ool is exhausted When the credential pool exists but contains no usable entry (all previously tried keys failed), _try_openrouter() was returning (None, None) instead of falling through to the OPENROUTER_API_KEY env var. Changed the guard to check both pool_present AND entry is not None, and restructured so that when the pool has no usable key the code continues to the env-var fallback path instead of exiting early. Fixes: NousResearch#23452
305feb8 to
19905e6
Compare
Author
|
Thanks for the review. I've rebuilt the branches from latest main — each PR now contains only its single targeted fix instead of stacked commits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using the credential pool for OpenRouter, if the pool exists but contains no usable keys (all previously tried entries failed),
_try_openrouter()currently exits early withNone, Nonewithout falling through to theOPENROUTER_API_KEYenvironment variable.This fix ensures that when a credential pool is present but has no usable entry, the code continues to check the
OPENROUTER_API_KEYenv var as a fallback.Root cause
The condition
if pool_present:was true even when no valid entry was found, causing an early return before reaching the env var fallback logic.\n\n## FixChanged the early-return guard to check both
pool_presentANDentry is not None, allowing the fallthrough when the pool is empty of usable keys.Fixes #23452