feat: add ENABLE_BYOR_EXPORT env var and frontend feature flag - #232
Open
tofarr wants to merge 4 commits into
Open
feat: add ENABLE_BYOR_EXPORT env var and frontend feature flag#232tofarr wants to merge 4 commits into
tofarr wants to merge 4 commits into
Conversation
Add an `ENABLE_BYOR_EXPORT` environment variable that short-circuits the `check_byor_export_enabled` backend check so BYOR export is always enabled when set to true (accepts 'true' and '1'). Expose `enable_byor_export` as a frontend feature flag via the web client config so the frontend can gate the LLM key display on this flag instead of relying solely on HTTP 402 responses. On the API keys page, when billing is not enabled and BYOR export is not enabled, show a "disabled" message instead of the buy-credits paywall. Co-authored-by: openhands <openhands@all-hands.dev>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
Collapse the multi-line `check_byor_export_enabled` call in the env-var test onto a single line to match ruff's formatting rules. Co-authored-by: openhands <openhands@all-hands.dev>
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.
HUMAN:
AGENT:
Why
On deployments where billing is not enabled, the API keys page does not show LLM API keys to users. Instead it shows a "buy $10 of credit" paywall, which is misleading because there is no billing flow on self-hosted/enterprise deployments. We need a way for admins to enable LLM API key export via an environment variable, and for the UI to show an appropriate "disabled" message when neither billing nor the env var is active.
Summary
ENABLE_BYOR_EXPORTenvironment variable (accepts'true'and'1') that short-circuitscheck_byor_export_enabledin the backend so BYOR export is always enabled when set.enable_byor_exportas a frontend feature flag via the web client config injector andWebClientFeatureFlagsmodel.api-keys-manager.tsx) with three-way conditional rendering: (1) disabled message when billing is off AND BYOR export is off, (2) buy-credits paywall when billing is on and payment is required, (3) full LLM key manager otherwise.use-llm-api-key.tshook to fire the BYOR key fetch whenenable_byor_exportis true (not just in SaaS mode).SETTINGS$LLM_API_KEY_DISABLED_MESSAGEacross all 14 supported languages.How to Test
ENABLE_BYOR_EXPORT=trueand callcheck_byor_export_enabledfor a user with no credits / no org flag. It should returnTrueimmediately.ENABLE_BYOR_EXPORTunset (defaultfalse), the existing behavior is unchanged — the check proceeds to the billing/credits logic.ENABLE_BILLINGunset andENABLE_BYOR_EXPORTunset, the API keys page should show "LLM API key export is disabled on this deployment. Contact your administrator to enable it." instead of the buy-credits paywall.ENABLE_BYOR_EXPORT=true(no billing). The API keys page should show the full LLM key manager with the key, refresh button, copy, and show/hide controls.PYTHONPATH=".:$PYTHONPATH" poetry run python -m pytest enterprise/tests/unit/test_org_service.py -k byor_export(7 tests pass) andcd frontend && npx vitest run __tests__/components/features/settings/api-keys-manager.test.tsx(4 tests pass).Type
Notes
The
ENABLE_BYOR_EXPORTenv var accepts both'true'and'1'as truthy values, following the repository convention for env var enable toggles (older Helm charts default to'1'). The_env_flag_enabledhelper indefault_web_client_config_injector.pywas reused for the frontend flag.Pull request created by an AI agent (OpenHands) on behalf of the user.
Enterprise server image for this PR: