Skip to content

feat(dashboard): disable adding providers when OTARI_SECRET_KEY is unset#391

Merged
njbrake merged 1 commit into
mainfrom
gray_out_providers
Jul 23, 2026
Merged

feat(dashboard): disable adding providers when OTARI_SECRET_KEY is unset#391
njbrake merged 1 commit into
mainfrom
gray_out_providers

Conversation

@njbrake

@njbrake njbrake commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

Provider credentials are encrypted at rest with OTARI_SECRET_KEY, so storing one over the API fails when it is unset. Before this change, an operator could pick a provider, paste a key, fill out the whole add-provider form, and only discover on submit that the gateway could not store it.

This surfaces the state up front:

  • The settings endpoint (GET /v1/settings) now reports secret_key_configured, derived from secret_box_configured(). Startup validation already rejects an invalid key, so true here means present and valid.
  • The Providers page disables both the header Add provider button and the first-run Add your first provider button when the key is unset, and shows a warning banner explaining that OTARI_SECRET_KEY must be set on the server (providers defined in config.yml keep working without it).

The flag defaults to "configured" while settings are still loading and when an older gateway omits the field, so the buttons never falsely gray out.

PR Type

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation
  • Infrastructure / CI

Relevant issues

N/A

Checklist

  • I understand the code I am submitting.
  • I have added or updated tests that cover my change (tests/unit, tests/integration).
  • I ran the Definition of Done checks locally (make lint, make typecheck, make test).
  • Documentation was updated where necessary.
  • If the API contract changed, I regenerated the OpenAPI spec (uv run python scripts/generate_openapi.py).

AI Usage

  • No AI was used.
  • AI was used for drafting/refactoring.
  • This is fully AI-generated.

AI Model/Tool used:

Claude Code (Opus 4.8)

Any additional AI details you'd like to share:

Implemented and reviewed via Claude Code with back-and-forth direction from @njbrake.

NOTE:
When responding to reviewer questions, please respond yourself rather than copy/pasting reviewer comments into an AI and pasting back its answer. We want to discuss with you, not your AI :)

  • I am an AI Agent filling out this form (check box if true)

@njbrake
njbrake temporarily deployed to integration-tests July 23, 2026 16:39 — with GitHub Actions Inactive
@github-actions github-actions Bot added the missing-template PR is missing required template sections label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@njbrake, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 54486806-d6bb-4d24-90a2-da87b83594e4

📥 Commits

Reviewing files that changed from the base of the PR and between 5c5dbaa and 606ca4a.

⛔ Files ignored due to path filters (1)
  • docs/public/openapi.json is excluded by !docs/public/openapi.json
📒 Files selected for processing (22)
  • src/gateway/api/routes/settings.py
  • src/gateway/static/dashboard/assets/ActivityPage-BJQNqIHi.js
  • src/gateway/static/dashboard/assets/AliasesPage-C2JIWSiZ.js
  • src/gateway/static/dashboard/assets/BudgetsPage-inMAr92N.js
  • src/gateway/static/dashboard/assets/KeysPage-0Svam5tu.js
  • src/gateway/static/dashboard/assets/ModelScopeControl-DTCXvnvU.js
  • src/gateway/static/dashboard/assets/ModelsPage-CN4L8fzW.js
  • src/gateway/static/dashboard/assets/OverviewPage-D4ZtkmU0.js
  • src/gateway/static/dashboard/assets/ProvidersPage-CmlcXh68.js
  • src/gateway/static/dashboard/assets/SettingsPage-UC2EHTIR.js
  • src/gateway/static/dashboard/assets/ToolsGuardrailsPage-rcsPeR9V.js
  • src/gateway/static/dashboard/assets/UsagePage-XCUoRhxb.js
  • src/gateway/static/dashboard/assets/UsersPage-EoUcpZFH.js
  • src/gateway/static/dashboard/assets/index-DHQmS-9o.js
  • src/gateway/static/dashboard/index.html
  • tests/unit/test_settings_endpoint.py
  • web/src/api/types.ts
  • web/src/components/PricingWarning.test.tsx
  • web/src/pages/ModelsPage.test.tsx
  • web/src/pages/ProvidersPage.test.tsx
  • web/src/pages/ProvidersPage.tsx
  • web/src/pages/SettingsPage.test.tsx

Walkthrough

The settings API now reports whether OTARI_SECRET_KEY is configured. The dashboard uses this value to warn about unavailable encryption and disable provider creation, with updated frontend types, tests, and regenerated static assets.

Changes

Secret key configuration gating

Layer / File(s) Summary
Settings API contract and validation
src/gateway/api/routes/settings.py, web/src/api/types.ts, tests/unit/test_settings_endpoint.py, web/src/components/PricingWarning.test.tsx, web/src/pages/ModelsPage.test.tsx, web/src/pages/SettingsPage.test.tsx
The settings response and frontend GatewaySettings type now include secret_key_configured, with endpoint coverage for configured and unconfigured secrets and updated fixtures.
Provider creation gating and tests
web/src/pages/ProvidersPage.tsx, web/src/pages/ProvidersPage.test.tsx
ProvidersPage displays an encryption warning and disables both provider-creation actions when the secret key is unavailable; tests cover stored-provider and first-run states.
Dashboard bundle wiring
src/gateway/static/dashboard/assets/*, src/gateway/static/dashboard/index.html
Regenerated assets update hashed chunk references, replace the Providers page bundle, and update the dashboard entrypoint.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: khaledosman

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title matches the change, but it uses feat(dashboard): instead of the required prefix and is a bit over the length limit. Rewrite it to start with an allowed prefix like feat: and keep it under ~70 characters, e.g. feat: disable provider adds when OTARI_SECRET_KEY is unset.
✅ Passed checks (3 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.
Description check ✅ Passed The description follows the repository template and includes the required sections, checklist, test notes, and AI usage details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gray_out_providers
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch gray_out_providers

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.

@coderabbitai
coderabbitai Bot requested a review from khaledosman July 23, 2026 16:40
@github-actions github-actions Bot removed the missing-template PR is missing required template sections label Jul 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/src/api/types.ts (1)

528-531: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Model the legacy omission in the TypeScript contract.

ProvidersPage treats a missing secret_key_configured as configured for older gateways, but this interface says the field is always present. Make it optional so the type matches the supported wire contract.

As per coding guidelines, use undefined rather than null for absent values in own TypeScript types.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/api/types.ts` around lines 528 - 531, Update the TypeScript contract
containing secret_key_configured to mark this field optional, allowing it to be
omitted for legacy gateways while retaining boolean support when present; do not
model absence with null.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/pages/ProvidersPage.test.tsx`:
- Around line 333-350: Update the disabled-state assertions in the tests around
the stored-provider and first-run scenarios to await the settings-driven state
with waitFor. Keep the existing content checks, but wrap each
getByRole(...).toBeDisabled() assertion so it runs after /v1/settings resolves
and avoids the initial enabled state.

In `@web/src/pages/ProvidersPage.tsx`:
- Around line 719-722: Update the ProvidersPage settings gate around
secretKeyConfigured to fail closed when the settings request errors, while
preserving the initial loading and legacy-missing-field behavior. Pass the
resolved configuration flag into AddProviderForm and disable both of its “Add
provider” buttons whenever the flag is false, including when the form was opened
before settings resolved. Add a regression test covering that
form-open-before-settings-resolves scenario.

---

Nitpick comments:
In `@web/src/api/types.ts`:
- Around line 528-531: Update the TypeScript contract containing
secret_key_configured to mark this field optional, allowing it to be omitted for
legacy gateways while retaining boolean support when present; do not model
absence with null.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fd34359d-44dd-431d-af61-65c3c3218028

📥 Commits

Reviewing files that changed from the base of the PR and between de90d8a and 5c5dbaa.

⛔ Files ignored due to path filters (1)
  • docs/public/openapi.json is excluded by !docs/public/openapi.json
📒 Files selected for processing (23)
  • src/gateway/api/routes/settings.py
  • src/gateway/static/dashboard/assets/ActivityPage-GBOr6z1H.js
  • src/gateway/static/dashboard/assets/AliasesPage-CBlym97u.js
  • src/gateway/static/dashboard/assets/BudgetsPage-Ci2Om4P2.js
  • src/gateway/static/dashboard/assets/KeysPage-DWer2Zt4.js
  • src/gateway/static/dashboard/assets/ModelScopeControl-TznM9VoL.js
  • src/gateway/static/dashboard/assets/ModelsPage-16gTbAeA.js
  • src/gateway/static/dashboard/assets/OverviewPage-DJKN_XEh.js
  • src/gateway/static/dashboard/assets/ProvidersPage-BJkEklg1.js
  • src/gateway/static/dashboard/assets/ProvidersPage-X8B2lXUg.js
  • src/gateway/static/dashboard/assets/SettingsPage-X-q-HpC1.js
  • src/gateway/static/dashboard/assets/ToolsGuardrailsPage-jehHsX-2.js
  • src/gateway/static/dashboard/assets/UsagePage-BnXUYCG7.js
  • src/gateway/static/dashboard/assets/UsersPage-BHnbX63B.js
  • src/gateway/static/dashboard/assets/index-f58_9tRL.js
  • src/gateway/static/dashboard/index.html
  • tests/unit/test_settings_endpoint.py
  • web/src/api/types.ts
  • web/src/components/PricingWarning.test.tsx
  • web/src/pages/ModelsPage.test.tsx
  • web/src/pages/ProvidersPage.test.tsx
  • web/src/pages/ProvidersPage.tsx
  • web/src/pages/SettingsPage.test.tsx
💤 Files with no reviewable changes (1)
  • src/gateway/static/dashboard/assets/ProvidersPage-BJkEklg1.js

Comment thread web/src/pages/ProvidersPage.test.tsx Outdated
Comment thread web/src/pages/ProvidersPage.tsx Outdated
@njbrake
njbrake force-pushed the gray_out_providers branch from 5c5dbaa to 48448c2 Compare July 23, 2026 17:08
@njbrake
njbrake temporarily deployed to integration-tests July 23, 2026 17:08 — with GitHub Actions Inactive
Provider credentials are encrypted at rest with OTARI_SECRET_KEY, so
storing one over the API fails when it is unset. Previously the operator
could fill in the whole add-provider form and only hit the error on
submit. Surface the state up front instead: the settings endpoint now
reports secret_key_configured, and the Providers page disables the Add
provider buttons and shows a banner explaining that the key must be set
on the server (config.yml providers keep working without it).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@njbrake
njbrake force-pushed the gray_out_providers branch from 48448c2 to 606ca4a Compare July 23, 2026 19:41
@njbrake
njbrake temporarily deployed to integration-tests July 23, 2026 19:41 — with GitHub Actions Inactive
@njbrake
njbrake merged commit 661aafc into main Jul 23, 2026
11 checks passed
@njbrake
njbrake deleted the gray_out_providers branch July 23, 2026 19:49
@njbrake njbrake mentioned this pull request Jul 24, 2026
4 tasks
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