[PR #3435] [CLOSED] [GUI] Use web API keys immediately when browser storage fails #4634

Closed
opened 2026-11-07 15:37:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3435
Author: @engharat
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/web-api-key-persistence


📝 Commits (1)

  • 3afe9d4 [GUI] Use web API key immediately and retain it when storage fails

📊 Changes

2 files changed (+113 additions, -5 deletions)

View changed files

➕ serve/test_web_api_key.py (+99 -0)
📝 serve/web/app.js (+14 -5)

📄 Description

Problem and result

The web app saves its API key only on change (usually blur), and every request reads it back from localStorage. Before blur, an edited key is not used. If storage is blocked or full, the app discards the entered key, sends no key (or the old one), and still says “API key saved.”

The page now uses the trimmed key immediately on input, saves it when possible, and keeps using it in memory if storage fails. On change, it warns that the key must be entered again after reload when persistence is unavailable. Clearing the field removes Authorization. Existing stored keys and keyless servers keep working.

Related symptom: #725. This fixes the client-side event/storage paths, not server-side key normalization proposed in the closed #956.

Approach

Keep the current page's key in memory for the shared request-header helper. Have the existing storage setter report whether its write succeeded, so the notification does not claim persistence when the write failed. No new dependencies, server changes, authentication bypasses, or engine changes.

Validation

Linux, Python 3.14.4, Node v22.22.1. Final commit: 3afe9d4a.

Passed:

  • python3 -m unittest serve.test_web_api_key serve.test_web_sampling -v: 12 tests passed (8 API-key regressions, 4 existing sampling tests).
  • node --check serve/web/app.js and git diff --check.
  • Before the fix, the initial regression run failed on missing/stale Authorization and the false success notification; the same cases pass after the fix.
  • In Chromium against the running page at 127.0.0.1:8080, confirmed input updates Authorization and storage without blur. With Storage reads/writes forced to throw, confirmed Authorization still uses the edited key, a warning appears, and clearing the field removes Authorization. Test values were removed afterward.
  • Authenticated GET /metrics on the live server returned HTTP 200.

Failed / limits:

  • Broader .venv/bin/python -m unittest discover -s serve -t . run, before adding the final notification regression: 888 tests, 2 failures, 14 skipped. Failures were serve.test_keepawake.KeepAwakeTests.test_service_holds_for_the_whole_request_including_early_close and serve.test_responses.NoLeakedSampler.test_server_close_ends_the_sampler. The keepawake failure also reproduces against an exported unmodified parent revision (e88ee39d); the sampler test passes in isolation on both revisions. Neither was changed here.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3435 **Author:** [@engharat](https://github.com/engharat) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/web-api-key-persistence` --- ### 📝 Commits (1) - [`3afe9d4`](https://github.com/Niko1221/Strata/commit/3afe9d4acbe706daa5ee09a3f020a1810a464095) [GUI] Use web API key immediately and retain it when storage fails ### 📊 Changes **2 files changed** (+113 additions, -5 deletions) <details> <summary>View changed files</summary> ➕ `serve/test_web_api_key.py` (+99 -0) 📝 `serve/web/app.js` (+14 -5) </details> ### 📄 Description ## Problem and result The web app saves its API key only on `change` (usually blur), and every request reads it back from localStorage. Before blur, an edited key is not used. If storage is blocked or full, the app discards the entered key, sends no key (or the old one), and still says “API key saved.” The page now uses the trimmed key immediately on input, saves it when possible, and keeps using it in memory if storage fails. On change, it warns that the key must be entered again after reload when persistence is unavailable. Clearing the field removes Authorization. Existing stored keys and keyless servers keep working. Related symptom: #725. This fixes the client-side event/storage paths, not server-side key normalization proposed in the closed #956. ## Approach Keep the current page's key in memory for the shared request-header helper. Have the existing storage setter report whether its write succeeded, so the notification does not claim persistence when the write failed. No new dependencies, server changes, authentication bypasses, or engine changes. ## Validation Linux, Python 3.14.4, Node v22.22.1. Final commit: `3afe9d4a`. Passed: - `python3 -m unittest serve.test_web_api_key serve.test_web_sampling -v`: 12 tests passed (8 API-key regressions, 4 existing sampling tests). - `node --check serve/web/app.js` and `git diff --check`. - Before the fix, the initial regression run failed on missing/stale Authorization and the false success notification; the same cases pass after the fix. - In Chromium against the running page at `127.0.0.1:8080`, confirmed input updates Authorization and storage without blur. With Storage reads/writes forced to throw, confirmed Authorization still uses the edited key, a warning appears, and clearing the field removes Authorization. Test values were removed afterward. - Authenticated GET `/metrics` on the live server returned HTTP 200. Failed / limits: - Broader `.venv/bin/python -m unittest discover -s serve -t .` run, before adding the final notification regression: 888 tests, 2 failures, 14 skipped. Failures were `serve.test_keepawake.KeepAwakeTests.test_service_holds_for_the_whole_request_including_early_close` and `serve.test_responses.NoLeakedSampler.test_server_close_ends_the_sampler`. The keepawake failure also reproduces against an exported unmodified parent revision (`e88ee39d`); the sampler test passes in isolation on both revisions. Neither was changed here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4634
No description provided.