Skip to content

fix(api): make warn_deprecated_env_vars() actually read env vars - #6294

Open
shafeeq27edu-ai wants to merge 2 commits into
Agenta-AI:mainfrom
shafeeq27edu-ai:fix/warn-deprecated-env-vars-helpers
Open

fix(api): make warn_deprecated_env_vars() actually read env vars#6294
shafeeq27edu-ai wants to merge 2 commits into
Agenta-AI:mainfrom
shafeeq27edu-ai:fix/warn-deprecated-env-vars-helpers

Conversation

@shafeeq27edu-ai

@shafeeq27edu-ai shafeeq27edu-ai commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

The deprecation warning system for old environment variables was silently broken. getattr(env, old_var, None) always returned None because env is a module/object, not os.environ. No deprecation warnings were ever emitted.

Summary

What changed? Replaced getattr(env, old_var, None) with os.getenv(old_var) in warn_deprecated_env_vars() inside api/oss/src/utils/helpers.py.

Why was this change needed? env is 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 returned None, 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

  • Located the broken line: getattr(env, old_var, None) at helpers.py:141
  • Replaced with os.getenv(old_var)
  • Verified os is already imported at the top of the file
  • Ran ruff check api/oss/src/utils/helpers.py — passes with no errors
  • Ran ruff format api/oss/src/utils/helpers.py — no changes needed
  • Ran a local verification script setting a deprecated env var and confirmed the warning now prints

Added 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

image image

Checklist

  • Demo shows the real app running this branch (not a mock-up or recreated UI), or is marked N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

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.
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 0fccb5fc-b9d3-478a-9525-fd514618c9d2

📥 Commits

Reviewing files that changed from the base of the PR and between 00ac9be and 6cb3fdc.

📒 Files selected for processing (1)
  • api/oss/src/utils/helpers.py

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved environment variable detection for more reliable configuration handling.

Walkthrough

The helper now detects deprecated environment variables with direct process-environment lookups through os.getenv.

Changes

Deprecated environment detection

Layer / File(s) Summary
Use raw environment values
api/oss/src/utils/helpers.py
The helper imports os. warn_deprecated_env_vars uses os.getenv(old_var) to detect deprecated variables.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 6cb3f

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the fix to warn_deprecated_env_vars() and its environment-variable behavior.
Description check ✅ Passed The description accurately explains the broken behavior, the os.getenv() fix, the expected warning behavior, and the validation performed.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant