Skip to content

fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5272

Open
MilesQLi wants to merge 1 commit intocrewAIInc:mainfrom
MilesQLi:fix/create-crew-provider-variable-shadowing
Open

fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5272
MilesQLi wants to merge 1 commit intocrewAIInc:mainfrom
MilesQLi:fix/create-crew-provider-variable-shadowing

Conversation

@MilesQLi
Copy link
Copy Markdown

@MilesQLi MilesQLi commented Apr 4, 2026

Summary

Fixes #5270

In create_crew(), the for-loop for provider, env_keys in ENV_VARS.items() was reusing the name provider, which shadows the function parameter passed from the CLI's --provider flag. Renamed the loop variable to env_provider so the original parameter value is preserved.

The parameter isn't currently read after the loop (the function uses selected_provider from interactive selection), so this is a latent bug rather than a visible one today. But shadowing function parameters with loop variables is a classic Python gotcha that makes the code fragile and would trip up anyone trying to use provider later in the function.

Changes

  • Renamed providerenv_provider in the for-loop on line 214 and the assignment on line 219

Test plan

  • All 15 existing tests in test_create_crew.py pass
  • Verified no other references to the loop variable need updating
  • Existing CI should pass (no test changes)

In create_crew(), the for loop `for provider, env_keys in
ENV_VARS.items()` reused the name `provider`, clobbering the
function parameter after the loop. While the parameter is not
currently referenced post-loop, the shadowing is a latent bug
that would silently break any future use of the original value.
Renamed to `env_provider` to keep the parameter intact.
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.

[BUG] create_crew() loop variable shadows provider function parameter

1 participant