mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Fix dictionary changed size during iteration error in override_provider_tokens_with_custom_secret (#9728)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -290,12 +290,16 @@ class AgentSession:
|
||||
custom_secrets: CUSTOM_SECRETS_TYPE | None,
|
||||
):
|
||||
if git_provider_tokens and custom_secrets:
|
||||
tokens = dict(git_provider_tokens)
|
||||
for provider, _ in tokens.items():
|
||||
token_name = ProviderHandler.get_provider_env_key(provider)
|
||||
if token_name in custom_secrets or token_name.upper() in custom_secrets:
|
||||
del tokens[provider]
|
||||
|
||||
# Use dictionary comprehension to avoid modifying dictionary during iteration
|
||||
tokens = {
|
||||
provider: token
|
||||
for provider, token in git_provider_tokens.items()
|
||||
if not (
|
||||
ProviderHandler.get_provider_env_key(provider) in custom_secrets
|
||||
or ProviderHandler.get_provider_env_key(provider).upper()
|
||||
in custom_secrets
|
||||
)
|
||||
}
|
||||
return MappingProxyType(tokens)
|
||||
return git_provider_tokens
|
||||
|
||||
|
||||
Reference in New Issue
Block a user