agent window: plain message when the endpoint wants a key
Deploy web Studio / deploy (push) Successful in 3m16s

A 401/403 with an HTML error page (nginx) showed as "HTTP 401: 401
Authorization Required 401 Authorization Required nginx". Now: "The endpoint
wants an API key: enter it in ⚙" before one is set, "The endpoint refused
the API key (...)" after.
This commit is contained in:
grabowski committed 2026-10-23 19:57:29 +07:00
1 parent 41554801ea
commit 36f7a9f440
2 files changed
+9 -3

No files matched your search

+7 -2
View File
@@ -91,8 +91,13 @@
var m = t;
try { var x = JSON.parse(t); m = (x.error && (x.error.message || x.error)) || x.message || x.detail || t; } catch (e) { /* plain text */ }
if (typeof m !== "string") m = JSON.stringify(m);
m = m.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
var hint = r.status === 401 || r.status === 403 ? " Check the API key (⚙)." : r.status === 404 ? " Check the endpoint: most servers want the URL ending in /v1." : "";
if (/^\s*</.test(m)) m = ""; // an HTML error page says no more than the status
m = m.replace(/\s+/g, " ").trim();
if (r.status === 401 || r.status === 403) {
return new Error(A.cfg.has_key ? "The endpoint refused the API key (HTTP " + r.status + (m ? ": " + clip(m, 200) : "") + "). Check it in ⚙."
: "The endpoint wants an API key: enter it in ⚙ (HTTP " + r.status + ").");
}
var hint = r.status === 404 ? " Check the endpoint: most servers want the URL ending in /v1." : "";
return new Error("HTTP " + r.status + (m ? ": " + clip(m, 300) : "") + hint);
});
}