+
+
diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts
index 31eee7e7e..67941cc9d 100644
--- a/ui/src/lib/api.ts
+++ b/ui/src/lib/api.ts
@@ -47,13 +47,16 @@ function qs(params?: QueryParams): string {
// with http.Error, i.e. a plain-text reason -- "task is not awaiting
// approval", "max retries reached (3/3)", "Content-Type must be
// application/json" -- and discarding it in favour of "409 Conflict" throws
-// away the only part an operator can act on.
+// away the only part an operator can act on. Only a text/plain body is read:
+// a proxy's HTML error page must not pass through as the reason.
async function errorMessage(res: Response): Promise {
- try {
- const body = (await res.text()).trim();
- if (body) return body.split("\n")[0].slice(0, 200);
- } catch {
- // Body already consumed or unreadable; fall through to the status.
+ if ((res.headers.get("Content-Type") ?? "").includes("text/plain")) {
+ try {
+ const body = (await res.text()).trim();
+ if (body) return body.split("\n")[0].slice(0, 200);
+ } catch {
+ // Body already consumed or unreadable; fall through to the status.
+ }
}
return `${res.status} ${res.statusText}`;
}