[PR #569] [CLOSED] serve, setup: an empty API key is refused from the config file and from setup's --api-key (#213) #2697

Closed
opened 2026-11-04 02:02:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/569
Author: @gputier
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: pr/empty-api-key-0.1.37


📝 Commits (10+)

  • b0dda4b AMD: gfx1101 (RX 7800 XT, #254 by jhohertz) and gfx1200 (RX 9060 XT, #256 by Efeisot) as community-validated cards
  • cc97fcd setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each)
  • e9e2ba3 pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode
  • cacffa9 CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats
  • a348c7a Merge branch 'f-131-srv' into r131-q4
  • b93a00c Merge branch 'f-q4-on242' into r131-q4
  • 8f5148c CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on
  • 5ffda19 CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory)
  • ed6c124 #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down
  • 450149d --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV

📊 Changes

4 files changed (+81 additions, -0 deletions)

View changed files

📝 serve/server.py (+4 -0)
📝 serve/test_server.py (+53 -0)
📝 setup.py (+3 -0)
📝 tools/test_setup_choices.py (+21 -0)

📄 Description

#213 already refuses an explicitly empty key given as --api-key "" or as an empty STRATA_API_KEY (serve/server.py:2750-2756, commit 4d25c61). Two other ways to give a key are still open on v0.1.37, and both end with a server that runs without authentication and says nothing about it.

I ran serve.server.main() with the mock engine on an unmodified v0.1.37 and tried every way to give a key. These are refused with exit code 2: --api-key "", --api-key " ", --api-key=, STRATA_API_KEY="" and STRATA_API_KEY=" ". Abbreviations such as --api= are not a way in, argparse rejects them as ambiguous with --api-monitor. The two that start the server:

  1. "api_key": "" in the config file. The service gets the key "" and authentication is off (serve/server.py:2756, svc.api_key = a.api_key or cfg.get("api_key", "")). "api_key": null behaves the same. "api_key": 123 starts too, with an integer as the key. "api_key": " " starts with a key made of spaces.
  2. setup.py --api-key "". On an install, if a.api_key: (setup.py:3557) drops it, so no key is saved. On a start, keep={"api_key": a.api_key, ...} (setup.py:2968-2984) only filters out None, so start() writes "" into the config (setup.py:2588-2590), over an existing key if there was one, and the server then runs without one (case 1).

The fix is two checks. serve/server.py refuses a config api_key that is not a non-blank string, right after the config is read and before the engine loads, with the same kind of message as #213. setup.py refuses a blank --api-key with ap.error, next to the other argument checks. I left the existing argv check alone, it works.

Tests: 7 new ones, 5 in serve/test_server.py (EmptyApiKey) and 2 in tools/test_setup_choices.py (ApiKey). test_empty_key_in_the_config_refused and test_an_empty_key_is_refused fail on v0.1.37 without the change (the server starts with key "", setup exits 0). The other five pass before and after and pin what already works: empty argument, empty variable, a key from each of the three sources, and no key at all still starting.

Side effect: a config that already holds "api_key": "" (written by the setup path above, or by hand) now refuses to start, with a message that names the key. Before, it started without authentication.

I ran the Python suite in a python:3.12-slim container: 422 passed, 47 failed, and the same 47 fail on a clean v0.1.37. They are not related to this change. On Linux setup.EXE is "strata" (setup.py:191), so normalize() in tools/test_setup_golden.py:58 also rewrites the start of the log file name, which breaks the golden comparison, and test_prebuilt_hip_zip expects strata.exe. With EXE forced to "strata.exe" the whole suite passes (checked on the other branch: 417 passed, 0 failed). I did not touch it 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/569 **Author:** [@gputier](https://github.com/gputier) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/empty-api-key-0.1.37` --- ### 📝 Commits (10+) - [`b0dda4b`](https://github.com/Niko1221/Strata/commit/b0dda4b14886293575e5fe5c92e5ba6636adc4a1) AMD: gfx1101 (RX 7800 XT, #254 by jhohertz) and gfx1200 (RX 9060 XT, #256 by Efeisot) as community-validated cards - [`cc97fcd`](https://github.com/Niko1221/Strata/commit/cc97fcde526e1b2d4cbee39ba21e54a0ef7505b1) setup: AMD layer splits with --gpus (every chosen card a supported AMD arch; the engine compiled for each) - [`e9e2ba3`](https://github.com/Niko1221/Strata/commit/e9e2ba31abdc211a618b5faf7226732d40bbcf2b) pinned (#243 follow-up): the shared-memory-budget cap on the sliced pin is opt-in (STRATA_ARENA_PIN_GIB=auto) - by default the arena pins as in 0.1.30; on this 64 GB PC the cap pinned 26 instead of 30 GiB and cost ~20% prompt speed and 2-4% IQ3_S decode - [`cacffa9`](https://github.com/Niko1221/Strata/commit/cacffa95aff016939edd7c15534c0067ec0ee93c) CS-T speed: the file tier fetched in parallel, PCIe planning without file reads, a partial pin of the RAM tier, bit-exact AVX2 multi-token kernels for Q4_K / Q5_1 / Q8_0 experts, decode-only tier stats - [`a348c7a`](https://github.com/Niko1221/Strata/commit/a348c7a4ed64f5f7f24ce3f1cba2d1439f673fed) Merge branch 'f-131-srv' into r131-q4 - [`b93a00c`](https://github.com/Niko1221/Strata/commit/b93a00c65a21fcc5b6431b8091e348d2976259f0) Merge branch 'f-q4-on242' into r131-q4 - [`8f5148c`](https://github.com/Niko1221/Strata/commit/8f5148c14d34c404e8a2d6a45188088714f3c9bb) CS-T: the partial pin at most 24 GiB (STRATA_PARTIAL_PIN_GIB), the Q4_K/Q5_1/Q8_0 multi-token kernels from two tokens on - [`5ffda19`](https://github.com/Niko1221/Strata/commit/5ffda19098202b82943fc80281ce0eb34d8e08a3) CS-T: the GGUF-in-place prefetch asks Windows for all of a layer's missed slices at once (PrefetchVirtualMemory) - [`ed6c124`](https://github.com/Niko1221/Strata/commit/ed6c1244dcd31789007540cb9d8498fbd4134b7f) #253: the 8 GiB arena pin cap only under WDDM; STRATA_ARENA_PIN_GIB; the split's prompt chunk steps down - [`450149d`](https://github.com/Niko1221/Strata/commit/450149d3f248438d8a2526c600b5a75c3dbea6c6) --split-skip-if-fits (opt-in): an auto split runs on the main card alone when it holds every profiled expert + KV ### 📊 Changes **4 files changed** (+81 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+4 -0) 📝 `serve/test_server.py` (+53 -0) 📝 `setup.py` (+3 -0) 📝 `tools/test_setup_choices.py` (+21 -0) </details> ### 📄 Description #213 already refuses an explicitly empty key given as `--api-key ""` or as an empty `STRATA_API_KEY` (serve/server.py:2750-2756, commit 4d25c61). Two other ways to give a key are still open on v0.1.37, and both end with a server that runs without authentication and says nothing about it. I ran serve.server.main() with the mock engine on an unmodified v0.1.37 and tried every way to give a key. These are refused with exit code 2: `--api-key ""`, `--api-key " "`, `--api-key=`, `STRATA_API_KEY=""` and `STRATA_API_KEY=" "`. Abbreviations such as `--api=` are not a way in, argparse rejects them as ambiguous with `--api-monitor`. The two that start the server: 1. `"api_key": ""` in the config file. The service gets the key "" and authentication is off (serve/server.py:2756, `svc.api_key = a.api_key or cfg.get("api_key", "")`). `"api_key": null` behaves the same. `"api_key": 123` starts too, with an integer as the key. `"api_key": " "` starts with a key made of spaces. 2. `setup.py --api-key ""`. On an install, `if a.api_key:` (setup.py:3557) drops it, so no key is saved. On a start, `keep={"api_key": a.api_key, ...}` (setup.py:2968-2984) only filters out `None`, so `start()` writes "" into the config (setup.py:2588-2590), over an existing key if there was one, and the server then runs without one (case 1). The fix is two checks. serve/server.py refuses a config `api_key` that is not a non-blank string, right after the config is read and before the engine loads, with the same kind of message as #213. setup.py refuses a blank `--api-key` with `ap.error`, next to the other argument checks. I left the existing argv check alone, it works. Tests: 7 new ones, 5 in serve/test_server.py (`EmptyApiKey`) and 2 in tools/test_setup_choices.py (`ApiKey`). `test_empty_key_in_the_config_refused` and `test_an_empty_key_is_refused` fail on v0.1.37 without the change (the server starts with key "", setup exits 0). The other five pass before and after and pin what already works: empty argument, empty variable, a key from each of the three sources, and no key at all still starting. Side effect: a config that already holds `"api_key": ""` (written by the setup path above, or by hand) now refuses to start, with a message that names the key. Before, it started without authentication. I ran the Python suite in a python:3.12-slim container: 422 passed, 47 failed, and the same 47 fail on a clean v0.1.37. They are not related to this change. On Linux `setup.EXE` is "strata" (setup.py:191), so `normalize()` in tools/test_setup_golden.py:58 also rewrites the start of the log file name, which breaks the golden comparison, and `test_prebuilt_hip_zip` expects `strata.exe`. With `EXE` forced to "strata.exe" the whole suite passes (checked on the other branch: 417 passed, 0 failed). I did not touch it here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:27 +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#2697
No description provided.