fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5274
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
fix: rename loop variable to avoid shadowing provider parameter in create_crew()#5274devin-ai-integration[bot] wants to merge 1 commit intomainfrom
provider parameter in create_crew()#5274devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…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>
Contributor
Author
|
Prompt hidden (unlisted session) |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Fixes #5270. In
create_crew(), theforloop iterating overENV_VARSusedprovideras its loop variable, shadowing theproviderfunction parameter. After the loop,providerheld the last key fromENV_VARS(or the key wherebreakwas hit) instead of the caller's original value.Renamed the loop variable from
providertoenv_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
create_crew.py:214now usesenv_providerand correctly assignsexisting_provider = env_provider— no other references to the old loop variable remainproviderparam 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
--providerCLI flag doesn't bypass interactiveselect_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()’sproviderparameter from being accidentally overwritten while iteratingENV_VARSby renaming the loop variable and ensuringexisting_provideris 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.