server: a null control_vector is "not sent", and the alias yields to the field

Reading the field's own name last made a null canonical value win over a
non-null alias (JSON null leaves the parsed bool untouched, so it became an
explicit off) and made a malformed alias fail a body whose canonical field was
valid. The loop now walks the field first, skips absent and null keys as the
rest of the parser does, and stops at the first one it finds: the field wins,
null means "the deployment's default", and the alias is only read when the field
is not.

server_test covers both -- a body with both spellings, and a null field with the
default on -- and cvec_test pins n_dirs, which the startup line now prints.
This commit is contained in:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent cd1f2f59cc
commit 071d204252
3 files changed
+28 -11

No files matched your search

+17 -3
View File
@@ -4538,9 +4538,13 @@ TEST(the_control_vector_field_overrides_the_default_or_is_refused) {
f.sched.join_all();
CHECK_EQ(r.status, 400);
CHECK(r.body.find("control_vector") != std::string::npos);
/* The route itself is present and answers 404: that is what the page tests for before it
* hides the panel, and what distinguishes "no vector here" from "not signed in". */
CHECK_EQ(f.get("/admin/control-vector").status, 404);
/* The route itself is present and answers 404 on both methods: that is what the page tests
* for before it hides the panel, and what distinguishes "no vector here" from "not signed
* in". */
const HttpResponse g0 = f.get("/admin/control-vector");
CHECK_EQ(g0.status, 404);
CHECK(g0.body.find("not_found_error") != std::string::npos);
CHECK_EQ(f.post("/admin/control-vector", R"({"enabled":true})").status, 404);
}
{
/* A vector loaded, default off: the request's own choice wins and reaches the engine. */
@@ -4582,6 +4586,16 @@ TEST(the_control_vector_field_overrides_the_default_or_is_refused) {
CHECK_EQ(r3.status, 200);
CHECK(!f.sched.last_sp.use_control_vector);
/* A JSON null is "not sent", not "false": the deployment's default (on, here) applies. */
HttpResponse r4 = f.post("/v1/chat/completions",
R"({"messages":[{"role":"user","content":"hi"}],
"max_tokens":4,
"control_vector":null})");
if (r4.streaming()) drain(r4);
f.sched.join_all();
CHECK_EQ(r4.status, 200);
CHECK(f.sched.last_sp.use_control_vector);
const HttpResponse g = f.get("/admin/control-vector");
CHECK_EQ(g.status, 200);
CHECK(g.body.find("\"default\":true") != std::string::npos);