fix(api): make warn_deprecated_env_vars() actually read env vars - #6294
fix(api): make warn_deprecated_env_vars() actually read env vars#6294shafeeq27edu-ai wants to merge 2 commits into
Conversation
The deprecation warning system was a no-op because it used getattr(env, old_var, None), which always returns None. env is a module/object, not os.environ. Changed to os.getenv(old_var) so deprecation warnings actually fire when users set old environment variable names. Verified with local test script showing warnings now emit correctly.
|
@shafeeq27edu-ai is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe helper now detects deprecated environment variables with direct process-environment lookups through ChangesDeprecated environment detection
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized fix makes deprecated environment-variable warnings read the actual process environment; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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
The deprecation warning system for old environment variables was silently broken.
getattr(env, old_var, None)always returnedNonebecauseenvis a module/object, notos.environ. No deprecation warnings were ever emitted.Summary
What changed? Replaced
getattr(env, old_var, None)withos.getenv(old_var)inwarn_deprecated_env_vars()insideapi/oss/src/utils/helpers.py.Why was this change needed?
envis a module/object imported at the top of the file.getattr(env, "SOME_VAR", None)looks for an attribute on that Python object, not an environment variable in the process. It always returnedNone, making the entire deprecation warning loop a no-op.What problem does it solve? Deprecation warnings now actually fire when users set old environment variable names, guiding them to migrate to the new names.
How the change addresses the root cause:
os.getenv()reads the actual process environment (os.environ), which is what this function intended to check all along.Testing
Verified locally
getattr(env, old_var, None)athelpers.py:141os.getenv(old_var)osis already imported at the top of the fileruff check api/oss/src/utils/helpers.py— passes with no errorsruff format api/oss/src/utils/helpers.py— no changes neededAdded or updated tests
N/A — This is a 1-line fix to existing functionality. The function's behavior is now correct; no new test infrastructure needed.
QA follow-up
N/A — The fix is self-contained and verified by static analysis and local script.
Demo
Checklist