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

+7 -5
View File
@@ -846,14 +846,16 @@ static int parse_sampling(const json& b, const OaiLimits& lim, OaiRequest* r, Ap
/* The control vector (core/cvec.h): an opt-in per request, and the only place an API client
* turns it on when the deployment's default is off. `control_vector` is the field's name;
* `experimental_speed_projection` is Strata's spelling of the same switch, kept as an alias so
* a client written against that reports what it means. */
/* The field's own name is read last, so a request that sends both spellings is read as
* `control_vector`; the alias is Strata's name for the same switch. */
for (const char* key : { "experimental_speed_projection", "control_vector" }) {
if (!b.contains(key)) continue;
* a client written against that reports what it means -- and read only when the request did not
* send the field itself, so the field wins when a body carries both. A JSON null is "not sent",
* as everywhere else in this parser. */
for (const char* key : { "control_vector", "experimental_speed_projection" }) {
const auto it = b.find(key);
if (it == b.end() || it->is_null()) continue;
bool on = false;
if (!get_bool(b, key, &on, err)) return RAD_E_INVAL;
r->control_vector = on ? 1 : 0;
break;
}
/* stop: a string or an array of strings. Bounded in count and length because every stop