Skip to content

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

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775307303-fix-provider-shadowing
Open

fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5274
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775307303-fix-provider-shadowing

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Apr 4, 2026

Summary

Fixes #5270. In create_crew(), the for loop iterating over ENV_VARS used provider as its loop variable, shadowing the provider function parameter. After the loop, provider held the last key from ENV_VARS (or the key where break was hit) instead of the caller's original value.

Renamed the loop variable from provider to env_provider — a one-line fix (two occurrences).

Added three regression tests covering the ENV_VARS loop with and without matching env vars, and the early-return path when the user declines to override an existing provider.

Review & Testing Checklist for Human

  • Verify the loop at create_crew.py:214 now uses env_provider and correctly assigns existing_provider = env_provider — no other references to the old loop variable remain
  • Note: the bug is currently latent (the provider param isn't read after the loop today), so the new tests exercise the code paths but can't produce a hard failure against the old code. Confirm you're comfortable with that coverage level.

Notes

  • The issue also mentions that the --provider CLI flag doesn't bypass interactive select_provider() — that's a separate issue and not addressed here.

Link to Devin session: https://app.devin.ai/sessions/c91e9f29d3c54447833be29784c7d6ba


Note

Low Risk
Low risk: a one-line rename to prevent parameter shadowing, plus new mocked CLI tests; minimal behavior change confined to crew creation flow.

Overview
Prevents create_crew()’s provider parameter from being accidentally overwritten while iterating ENV_VARS by renaming the loop variable and ensuring existing_provider is set from the correct value.

Adds regression tests covering (1) env var matches with override confirmation, (2) no env var match path, and (3) early return when the user declines to override an existing provider config.

Reviewed by Cursor Bugbot for commit 1086d5d. Bugbot is set up for automated code reviews on this repo. Configure here.

…eate_crew()

Fixes #5270. The for-loop iterating over ENV_VARS used 'provider' as its
loop variable, which shadowed the 'provider' function parameter. Renamed
the loop variable to 'env_provider' so the original parameter value is
preserved throughout the function.

Added three regression tests to verify the fix.

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Prompt hidden (unlisted session)

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the size/M label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

0 participants