Skip to content

fix(dashboard): surface auth-required banner for guest-session database settings (#12709) - #13270

Merged
diegosouzapw merged 1 commit into
release/v3.8.51from
fix/12709-guest-import-settings
Sep 12, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.51from
fix/12709-guest-import-settings

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Closes #12709

Root cause

/api/settings/database and /api/settings/import-json are intentionally listed in
ALWAYS_PROTECTED_API_PATHS (src/server/authz/routeGuard.ts:117-141), a deliberate hardening
fix for GHSA-mghq-58h3-qcqj and GHSA-v7g9-7f55-5g46. A guest/anonymous session (fresh install,
setup wizard skipped, no admin password configured) correctly gets a 401 AUTH_001 from both
endpoints — that gate is intentional and is not touched by this PR.

The actual bug was client-side: SystemStorageTab.tsx (Settings → General) fetched
/api/settings/database on mount and collapsed any non-2xx response, including this 401, to
null with zero error state. Every database-settings render helper is gated on
if (dbSettingsLoading || !dbSettings) return null;, so the whole section silently disappeared
instead of showing any explanation — matching the reporter's "Failed to load settings"
description. The JSON-import POST path (handleJsonSelected) had the same blind spot: a guest
401 just showed the generic "Failed to import JSON" text.

Fix

  • Extracted the fetch/401-detection logic into a new module,
    src/app/(dashboard)/dashboard/settings/components/systemStorageAuth.tsx
    (fetchDatabaseSettingsData, isAuthRequiredResponse, AuthRequiredBanner) — SystemStorageTab.tsx
    is at its frozen file-size baseline (1597 LOC), so new logic had to live in a new file rather
    than growing the frozen one.
  • SystemStorageTab.tsx now tracks dbSettingsAuthRequired and renders an explicit
    "Authentication required" banner (with a sign-in CTA) in place of the silently-blank section.
  • The JSON-import failure path now shows a dedicated "authentication required" message
    (jsonImportAuthRequired) instead of the generic import-failed text when the response is the
    intentional 401.
  • Added the corresponding en.json strings (databaseSettingsAuthRequiredTitle/Body/Cta,
    jsonImportAuthRequired).

ALWAYS_PROTECTED_API_PATHS, isAlwaysProtectedPath, and managementPolicy's handling of these
two routes were not modified — the 401 stays intentional and correct.

Regression test (TDD, Hard Rule #18)

tests/unit/ui/system-storage-tab-guest-401-12709.test.tsx mounts the real SystemStorageTab
component with fetch mocked to return the exact 401/AUTH_001 payload from the issue for
/api/settings/database, then asserts the rendered text mentions auth/login/401/unauthorized.

  • RED (confirmed against the unfixed component, base release/v3.8.51 content):
    npx vitest run tests/unit/ui/system-storage-tab-guest-401-12709.test.tsx →
    AssertionError: expected false to be true at the mentionsAuth assertion.
  • GREEN (with the fix applied): same command → 1 passed.

Gates run

  • node scripts/check/check-file-size.mjs → OK (138 frozen files, cap 1200 for new files;
    SystemStorageTab.tsx stays exactly at its 1597-line baseline)
  • node scripts/check/check-complexity.mjs → OK (2798 violations vs baseline 3218)
  • node scripts/check/check-cognitive-complexity.mjs → OK (1265 violations vs baseline 1437)
  • npm run typecheck:core → clean
  • npm run check:dashboard-typecheck → OK, 206 pre-existing errors, all within frozen baseline
    (no new errors in the touched files)
  • npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files> →
    clean
  • npx vitest run tests/unit/ui/system-storage-tab-guest-401-12709.test.tsx → 1 passed (new
    regression test)
  • Existing area tests re-run and still green: tests/unit/settings-ui-layout-static.test.ts,
    tests/unit/dashboard-localization-contract.test.ts,
    tests/unit/quota-card-grid-mobile-7072.test.ts (23/23 passed via
    node --import tsx/esm --test)
  • node scripts/check/check-changelog-integrity.mjs → OK

⚠️ base-red inherited: #12732 — unit #12058, integration codex-cache, package-artifact, tarball-smoke, agent-skills-sync

…se settings (#12709)

/api/settings/database and /api/settings/import-json are intentionally
ALWAYS_PROTECTED (GHSA-mghq-58h3-qcqj, GHSA-v7g9-7f55-5g46) and correctly
401 a guest/anonymous session. SystemStorageTab.tsx silently collapsed
that 401 to null, so the entire database-settings section of Settings ->
General just disappeared with zero explanation ("Failed to load
settings").

Extract the fetch/detection logic into systemStorageAuth.tsx (new module,
keeps SystemStorageTab.tsx within its frozen file-size baseline) and
surface an explicit auth-required banner plus a dedicated JSON-import
error message instead of a blank page.
@diegosouzapw
diegosouzapw merged commit 57d9e74 into release/v3.8.51 Sep 12, 2026
15 of 21 checks passed
diegosouzapw added a commit that referenced this pull request Sep 15, 2026
… the Igbo "Model" copy

The eight batch-2 catalogs (km, kn, ml, my, ne, or, pa, si) were generated
before #12551, #13270 and two other base changes added 10 keys to en.json,
and #13660 landed without re-syncing them — `home.topologyLegend*` and
`settings.*AuthRequired*` were missing, which fails the home-widget catalog
test on the release tip. Translated the 10 keys into each of the eight.
Igbo `home.recentRequestsModel` now reads "Nlereanya" instead of the English
copy; Uzbek "Model" is a genuine cognate (plural "modellar") and is allowlisted
next to Croatian and Slovenian.
Githab-capibara added a commit to Githab-capibara/OmniRoute that referenced this pull request Sep 17, 2026
…se settings (cheaper-inference#12709) (cheaper-inference#13270)

Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit.

Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them.

- ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on cheaper-inference#13243)
- `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline
- 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs
- `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for cheaper-inference#13278 and cheaper-inference#13276, annotated and landed on cheaper-inference#13243

⚠️ base-red inherited: cheaper-inference#12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…se settings (cheaper-inference#12709) (cheaper-inference#13270)

Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit.

Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them.

- ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on cheaper-inference#13243)
- `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline
- 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs
- `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for cheaper-inference#13278 and cheaper-inference#13276, annotated and landed on cheaper-inference#13243

⚠️ base-red inherited: cheaper-inference#12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
@diegosouzapw
diegosouzapw deleted the fix/12709-guest-import-settings branch October 18, 2026 23:48
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.

[BUG] Importing JSON configuration in guest session causes Settings to show "Failed to load settings"

1 participant