Repository navigation
feat(service-accounts): put service accounts behind the ENABLE_SERVICE_ACCOUNTS feature flag - #1088
Draft
henriquehirako wants to merge 5 commits into
Draft
henriquehirako wants to merge 5 commits into
henriquehirako wants to merge 5 commits into
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
henriquehirako
force-pushed
the
feat/ohe-3713-service-accounts-ui
branch
2 times, most recently
from
October 30, 2026 14:06
7c26041 to
6792edc
Compare
Gate every service_accounts_router route on the ENABLE_SERVICE_ACCOUNTS database flag (env var fallback, default off), expose it in the web-client config, hide /settings/service-accounts while it is off, and add a Super Admin Instance switch that writes the database flag. Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
henriquehirako
force-pushed
the
feat/ohe-3713-service-accounts-ui
branch
from
October 30, 2026 20:56
6792edc to
6280145
Compare
henriquehirako
force-pushed
the
openhands/ohe-3795
branch
from
October 30, 2026 20:56
209d7df to
90eb9e6
Compare
…nfig refetch returns The switch was enabled again with the old value while the config refetched. It now shows the saved value at once and stays disabled until the refetch finishes.
This branch has not been deployed
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
Service accounts must stay hidden until a Super Admin turns them on.
ENABLE_SERVICE_ACCOUNTSis a database feature flag that falls back to an env var of the same name (defaultfalse), the same wayENABLE_BILLINGworks. The switch on the Super Admin Instance page writes the flag, so no redeploy is needed.Summary
ENABLE_SERVICE_ACCOUNTSis now in_ENV_FLAG_DEFAULTS. The newvalidate_service_accounts_enabled()dependency onservice_accounts_routerreturns 403 on every/api/organizations/{org_id}/service-accounts*route while the flag is off. It is a copy ofvalidate_billing_enabled, and the 403 detail names the flag and the env var.WebClientFeatureFlags.enable_service_accountstakes the env value as a fallback in_get_feature_flags.get_web_client_configthen resolves it again with_resolve_flag('ENABLE_SERVICE_ACCOUNTS', ...), so a database row wins over the env var.isSettingsPageHiddenhides/settings/service-accounts(both the route loader and the nav entry) unlessenable_service_accountsis true.adminServicegetscreateFeatureFlagandupdateFeatureFlag.useSetServiceAccountsEnabled. It sendsPATCH, and if that returns 404 it sendsPOST. On success it invalidates the web-client config query.SettingsSwitchwithtestId="super-admin-instance-enable-service-accounts". The switch is disabled while a save is in progress.SUPER_ADMIN$INSTANCE_ENABLE_SERVICE_ACCOUNTS("Enable Service Accounts (beta)").How each acceptance criterion is met
service_accounts_routerroute returns 403Depends(validate_service_accounts_enabled)test_routes_return_403_when_flag_is_offchecks all 10 routes.test_every_route_is_gatedcompares the tested routes with the router's by method and path, so a new route fails until it is added./settings/service-accountsand its nav entry are hiddenisSettingsPageHiddensettings-utils.test.ts,use-settings-nav-items.test.tsx("hides service accounts while enable_service_accounts is off"),service-accounts.test.tsx("redirects an owner away while enable_service_accounts is off")feature_flag_service.resolvetest_routes_work_when_env_var_is_on[true/1],test_routes_work_when_database_row_is_on,test_database_row_wins_over_env_var. These run the real flag service against PostgreSQL. All existing route tests still pass with the gate open.GET /api/v1/web-client/configreturnsfeature_flags.enable_service_accounts, from the database row first, then the env vardefault_web_client_config_injector.pyTestEnableServiceAccounts(real database):test_env_var_when_no_row,test_database_row_wins,test_toggle_takes_effect_without_restartSuperAdminInstance+useSetServiceAccountsEnabledsuper-admin-instance.test.tsx: label and value shown,PATCHsent on toggle,POSTsent whenPATCHreturns 404, switch disabled while savingtest_toggle_takes_effect_without_restartIssue Number
OHE-3795
How to Test
These are the commands I ran on this branch, with their results:
uv run pre-commit run --config ./dev_config/python/.pre-commit-config.yaml(on the changed files): ruff, ruff format and mypy all passed.uv run pytest -n 4 --dist worksteal ./tests/unit: 9027 passed.uv run pytest tests/unit/server/routes/test_service_accounts.py tests/unit/app_server/test_default_web_client_config_injector.py tests/unit/server/services/test_feature_flag_service.py tests/unit/test_billing.py: all passed.cd frontend && npm run lint:fix && npm run lint(this includestsc): passed, with 0 errors.cd frontend && npm run build: passed.cd frontend && npx vitest run: 3260 passed across 360 test files (2 skipped), with 0 failures.ProgressEvent is not defined" errors from MSW's XHR interceptor during test teardown.feat/ohe-3713-service-accounts-uigave 3 such errors (fromapp-settings,agent-settingsandinteractive-chat-box).service-accounts.test.tsx. That file passed with no error when run on its own, twice.Local run (switch on → off → on, one server process, no restart)
Setup:
make local-db, migrated to head.feature_flag_router,service_accounts_router,FeatureFlagServiceandDefaultWebClientConfigInjector.In the frontend, the nav entry and the route follow
feature_flags.enable_service_accountsthroughisSettingsPageHidden. The mutation invalidates the config query, so the page picks up the change without a reload.I did not test the full UI end to end in a browser: the SaaS stack (Keycloak and the Super Admin login) was not available in this sandbox.
Video/Screenshots
None. See the local run output above.
Type
Notes
ENABLE_SERVICE_ACCOUNTS=true._get_feature_flagsuses_env_flag_enabled(acceptstrueor1). The ticket text used== 'true', but the repo's AGENTS.md rule requires accepting both values. This also matches what the backend gate accepts.createMockWebClientConfigdefault is unchanged (enable_service_accountsis absent, so the flag reads as off). The existing service-account route tests and nav tests now turn the flag on explicitly.This PR was created by an AI agent (OpenHands) on behalf of the ticket author.
@henriquehirako can click here to continue refining the PR
Enterprise server image for this PR: