[PR #4934] [Other] serve: one unknown key in .shared-settings.json no longer clears the rest (#4933) #5254

Open
opened 2026-11-07 16:33:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4934
Author: @dan64
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: serve/shared-settings-tolerate-unknown


📝 Commits (1)

  • 15ae1ea serve: one unknown key in .shared-settings.json no longer clears the rest (#4933)

📊 Changes

2 files changed (+97 additions, -7 deletions)

View changed files

📝 serve/server.py (+35 -7)
📝 serve/test_server.py (+62 -0)

📄 Description

Fixes #4933.

Problem and result

One unknown key in a config's .shared-settings.json emptied every shared Chat setting, silently. The start-up
path reused the strict reader that POST /settings uses, and swallowed its ValueError with svc.shared = {}:

# serve/server.py, before this PR
try:
    svc.shared = clean_shared_defaults(json.loads(Path(svc.shared_path).read_text(encoding="utf-8")))
    if svc.shared:
        print("[strata] other apps use the Chat settings: " + ...)
except (OSError, ValueError):
    svc.shared = {}

So one key the server did not recognise — a typo, a key from a newer version — also dropped reasoning_effort written
next to it, and nothing in the log said so. Reproduced with two boots in #4933: with
{"reasoning_effort":"medium","preserve_thinking":false} the start-up line
other apps use the Chat settings: ... does not appear at all; with {"reasoning_effort":"medium"} alone it does.

After this PR, the same file boots with:

[strata] one Chat setting in <path> is skipped (unknown setting 'preserve_thinking'); the others still apply
[strata] other apps use the Chat settings: reasoning_effort=medium

Issue #4933. Found while preparing #4932 (which makes preserve_thinking / preserve_reasoning known keys and so
hides the symptom for those two): the behaviour that matters is the one for any unknown key, and that is what this
PR changes. The two PRs touch different lines of serve/server.py and do not depend on each other.

Approach

load_shared_settings(path, warn=print) reads the file at start-up, key by key, and tells the three failures apart:

  • file missing → {}, no message: the normal case on a first start;
  • unreadable, not JSON, or not a JSON object → still ignored as a whole, because nothing in it can be trusted, and
    now one line says which file and why;
  • a key the server does not know, or a known key with a bad value → that key is named on one line and skipped; the
    others keep applying.

clean_shared_defaults is untouched and still raises, so POST /settings keeps answering a client with a 400 naming
the key
— that path did not change:

POST /settings {"reasoning_effort":"medium","nope":1}
  -> 400 {"error": {"type": "invalid_request_error", "message": "unknown setting 'nope'"}}

Compatibility: nothing that worked before behaves differently. A file that was read successfully is read to the same
dict; a file that used to clear everything now keeps its known keys, which is the fix. warn is a parameter so the
tests can read the messages instead of capturing stdout.

SHARED_KEYS is a separate, pre-existing tuple that nothing reads; I left it alone rather than bundle an unrelated
edit (it is updated in #4932 where new keys are added).

Validation

Environment: Windows 11 Pro 26300, i7-12700KF, RTX 5070 Ti 16 GB (sm_120), 111.8 GiB RAM; engine 0.1.51 (CUDA,
compiled locally); model Qwen3.8-Flash-Next Uncensored Q4_K_S, --ple-io direct, --kv q4_0, 524288 context.
Server: serve/server.py --engine strata --config <cfg>.json --port 9985.
Revision tested: 3e140618, on top of upstream c62d5e3a. The commit was then amended to 15ae1ea3, which changes
one thing: the example key in test_an_unknown_key_no_longer_clears_the_known_ones is now a made-up preserve_thoughts
instead of preserve_thinking (#4932 makes the latter a known key, so on a tree carrying both changes that test would
have passed without exercising anything). After that edit LoadSharedSettings was re-run alone: 7 passed. The full
pytest figure below was measured on 3e140618 and was not repeated.

Passed

  • python -m pytest serve/test_server.py serve/test_frontend.py -q — 389 passed, 3 skipped, 631 subtests passed in
    116.40 s, including the 7 new tests in LoadSharedSettings (two known keys kept; an unknown key no longer clears the
    others; a bad value named and skipped; several bad keys each named; unparsable file ignored whole and reported; a
    non-object ignored whole and reported; a missing file quiet).

  • Boot A on this revision, the exact file that failed in #4933 (reasoning_effort + preserve_thinking), stdout:

    [strata] one Chat setting in <path> is skipped (unknown setting 'preserve_thinking'); the others still apply
    [strata] other apps use the Chat settings: reasoning_effort=medium
    ready: http://127.0.0.1:9985/v1  (OpenAI: /v1/chat/completions, Anthropic: /v1/messages, context 524288 tokens, images on)
    

    Before the change the same file printed neither line (evidence in #4933).

  • POST /settings on the same running server: a bad key still answers 400 naming it; a valid body answers
    200 and applies.

Failed: none observed.

Not run

  • The --serve restart path that re-reads the file, and --batch / multi-slot modes with a corrupt settings file.
  • Windows and Linux were not both exercised: this ran on Windows only. The code is portable (no platform branch).
  • No GPU/CUDA/HIP build is involved: Python only, no engine source touched.

Limits

  • The tolerance is per key, not per value: a known key with a bad value is skipped rather than replaced with the
    default it would otherwise have had, so a file containing {"top_p": 5, "reasoning_effort": "medium"} leaves
    top_p unset rather than set to the server's default. POST /settings remains the path that refuses the whole body.
  • A file that is not an object is still dropped whole: the alternative (trying to salvage keys out of it) would be
    guessing at a shape the server never wrote.
  • Messages go through print at start-up, as the neighbouring lines do; they are not part of the structured
    /metrics or the monitor.

🔄 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/4934 **Author:** [@dan64](https://github.com/dan64) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `serve/shared-settings-tolerate-unknown` --- ### 📝 Commits (1) - [`15ae1ea`](https://github.com/Niko1221/Strata/commit/15ae1ea3293f89f1ee380fac0c40ce04f5346e67) serve: one unknown key in .shared-settings.json no longer clears the rest (#4933) ### 📊 Changes **2 files changed** (+97 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+35 -7) 📝 `serve/test_server.py` (+62 -0) </details> ### 📄 Description Fixes #4933. ## Problem and result One unknown key in a config's `.shared-settings.json` emptied **every** shared Chat setting, silently. The start-up path reused the strict reader that `POST /settings` uses, and swallowed its `ValueError` with `svc.shared = {}`: ```python # serve/server.py, before this PR try: svc.shared = clean_shared_defaults(json.loads(Path(svc.shared_path).read_text(encoding="utf-8"))) if svc.shared: print("[strata] other apps use the Chat settings: " + ...) except (OSError, ValueError): svc.shared = {} ``` So one key the server did not recognise — a typo, a key from a newer version — also dropped `reasoning_effort` written next to it, and nothing in the log said so. Reproduced with two boots in #4933: with `{"reasoning_effort":"medium","preserve_thinking":false}` the start-up line `other apps use the Chat settings: ...` **does not appear at all**; with `{"reasoning_effort":"medium"}` alone it does. After this PR, the same file boots with: ``` [strata] one Chat setting in <path> is skipped (unknown setting 'preserve_thinking'); the others still apply [strata] other apps use the Chat settings: reasoning_effort=medium ``` ## Related discussion Issue #4933. Found while preparing #4932 (which makes `preserve_thinking` / `preserve_reasoning` known keys and so hides the symptom for those two): the behaviour that matters is the one for **any** unknown key, and that is what this PR changes. The two PRs touch different lines of `serve/server.py` and do not depend on each other. ## Approach `load_shared_settings(path, warn=print)` reads the file at start-up, key by key, and tells the three failures apart: - **file missing** → `{}`, no message: the normal case on a first start; - **unreadable, not JSON, or not a JSON object** → still ignored as a whole, because nothing in it can be trusted, and now one line says which file and why; - **a key the server does not know, or a known key with a bad value** → that key is named on one line and skipped; the others keep applying. `clean_shared_defaults` is untouched and still raises, so `POST /settings` keeps answering a client with a **400 naming the key** — that path did not change: ``` POST /settings {"reasoning_effort":"medium","nope":1} -> 400 {"error": {"type": "invalid_request_error", "message": "unknown setting 'nope'"}} ``` Compatibility: nothing that worked before behaves differently. A file that was read successfully is read to the same dict; a file that used to clear everything now keeps its known keys, which is the fix. `warn` is a parameter so the tests can read the messages instead of capturing stdout. `SHARED_KEYS` is a separate, pre-existing tuple that nothing reads; I left it alone rather than bundle an unrelated edit (it is updated in #4932 where new keys are added). ## Validation Environment: Windows 11 Pro 26300, i7-12700KF, RTX 5070 Ti 16 GB (sm_120), 111.8 GiB RAM; engine 0.1.51 (CUDA, compiled locally); model Qwen3.8-Flash-Next Uncensored Q4_K_S, `--ple-io direct`, `--kv q4_0`, 524288 context. Server: `serve/server.py --engine strata --config <cfg>.json --port 9985`. Revision tested: **3e140618**, on top of upstream `c62d5e3a`. The commit was then amended to **15ae1ea3**, which changes one thing: the example key in `test_an_unknown_key_no_longer_clears_the_known_ones` is now a made-up `preserve_thoughts` instead of `preserve_thinking` (#4932 makes the latter a known key, so on a tree carrying both changes that test would have passed without exercising anything). After that edit `LoadSharedSettings` was re-run alone: **7 passed**. The full pytest figure below was measured on `3e140618` and was not repeated. **Passed** - `python -m pytest serve/test_server.py serve/test_frontend.py -q` — **389 passed, 3 skipped, 631 subtests passed** in 116.40 s, including the 7 new tests in `LoadSharedSettings` (two known keys kept; an unknown key no longer clears the others; a bad value named and skipped; several bad keys each named; unparsable file ignored whole and reported; a non-object ignored whole and reported; a missing file quiet). - **Boot A on this revision**, the exact file that failed in #4933 (`reasoning_effort` + `preserve_thinking`), stdout: ``` [strata] one Chat setting in <path> is skipped (unknown setting 'preserve_thinking'); the others still apply [strata] other apps use the Chat settings: reasoning_effort=medium ready: http://127.0.0.1:9985/v1 (OpenAI: /v1/chat/completions, Anthropic: /v1/messages, context 524288 tokens, images on) ``` Before the change the same file printed neither line (evidence in #4933). - `POST /settings` on the same running server: a bad key still answers **400** naming it; a valid body answers **200** and applies. **Failed:** none observed. **Not run** - The `--serve` restart path that re-reads the file, and `--batch` / multi-slot modes with a corrupt settings file. - Windows and Linux were not both exercised: this ran on Windows only. The code is portable (no platform branch). - No GPU/CUDA/HIP build is involved: Python only, no engine source touched. ## Limits - The tolerance is per key, not per value: a known key with a bad value is skipped rather than replaced with the default it would otherwise have had, so a file containing `{"top_p": 5, "reasoning_effort": "medium"}` leaves `top_p` unset rather than set to the server's default. `POST /settings` remains the path that refuses the whole body. - A file that is not an object is still dropped whole: the alternative (trying to salvage keys out of it) would be guessing at a shape the server never wrote. - Messages go through `print` at start-up, as the neighbouring lines do; they are not part of the structured `/metrics` or the monitor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5254
No description provided.