server: the control-vector switch answers 404 where it has no vector

The route's own comment, server.h and the dashboard's page all say a deployment
without a vector answers 404, and the page uses exactly that to tell "no vector
here" (hide the panel) from "not signed in" (show it, disabled). The handler
answered 501 instead, so such a deployment showed a panel claiming the vector was
present. The route now assembles the same 404 the server uses for a model it does
not serve, and the case that had no coverage -- a deployment without a vector --
checks it. The unreachable 405 arm goes: only GET and POST are registered.
This commit is contained in:
C_Tamas authored and StillDeadcode committed 2026-10-21 09:26:17 +02:00
1 parent cac79bb3ba
commit 6964d05f75
2 files changed
+13 -6

No files matched your search

+10 -6
View File
@@ -43,10 +43,16 @@ namespace server {
* no such feature, and its requests refuse `control_vector: true` by name. */
HttpResponse Server::handle_control_vector(const HttpRequest& req) {
const bool have = deps_.control_vector.available && deps_.control_vector.available();
if (!have)
return error_response(err_not_implemented(
"this deployment found no control vector for its model; there is nothing to switch"),
req.peer);
if (!have) {
/* 404, like a model the server does not serve: the route exists, this deployment has nothing
* behind it, and that is what the page tests for before hiding the panel. */
ApiError e;
e.status = 404;
e.type = "not_found_error";
e.message = "this deployment found no control vector for its model; there is nothing to "
"switch";
return error_response(e, req.peer);
}
if (req.method == "POST") {
json body;
@@ -62,8 +68,6 @@ HttpResponse Server::handle_control_vector(const HttpRequest& req) {
if (deps_.control_vector.set_default) deps_.control_vector.set_default(on);
RAD_INFO("control vector: default %s by an admin request%s", on ? "ON" : "OFF",
req.peer.empty() ? "" : (" from " + req.peer).c_str());
} else if (req.method != "GET") {
return HttpResponse::json_body(405, err_bad("method", "GET or POST").dump());
}
metrics_.observe_http(200);