fix(llm): strip trailing/leading whitespace from API keys across all …#5999
fix(llm): strip trailing/leading whitespace from API keys across all …#5999aryxnn wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR applies API key whitespace sanitization across all five LLM provider implementations in CrewAI. Each provider now trims leading and trailing whitespace from API keys at initialization and/or during deferred client setup to prevent credential validation failures from whitespace pollution. ChangesAPI Key Whitespace Sanitization
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
This PR resolves issue #5622 where valid API keys read from
.envfiles or environment variables fail with 401 invalid_api_key errors due to trailing or leading whitespace, newlines, or tabs.Changes
Automatically formats API keys by calling
.strip()across all native LLM providers (OpenAI, Anthropic, Gemini, Azure, and OpenAI-compatible).Summary by CodeRabbit
Bug Fixes