Skip to content

Commit ddb991d

Browse files
Rafael ReisRafael Reis
authored andcommitted
fix(zulip): clarify HTML non-JSON errors for 5xx upstream failures
1 parent 23da029 commit ddb991d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

extensions/zulip/src/zulip/client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,17 @@ export async function parseJsonOrThrow(res: Response): Promise<unknown> {
104104
const snippet = text.trim().slice(0, 240).replace(/\s+/g, " ");
105105

106106
if (looksLikeHtml) {
107+
const likelyCause =
108+
res.status >= 500
109+
? "This looks like an upstream/proxy error page (e.g. 502/503 from a reverse proxy, CDN, or load balancer), not a Zulip JSON API response. "
110+
: "This typically means an auth/SSO/proxy layer is intercepting API requests. ";
111+
107112
throw new Error(
108113
"Zulip API error: received HTML instead of JSON from /api. " +
109114
`HTTP ${res.status} (content-type: ${contentType || "unknown"}). ` +
110-
"This typically means an auth/SSO/proxy layer is intercepting API requests. " +
111-
"Allow bot access to /api/v1/* (service token / bypass policy) or use an internal API base URL. " +
115+
likelyCause +
116+
"If Zulip works in one environment but not another, compare DNS (IPv6 vs IPv4), egress network/proxy, and reverse-proxy timeouts for long-polling (/api/v1/events). " +
117+
"If applicable, allow bot access to /api/v1/* (service token / bypass policy) or use an internal API base URL. " +
112118
(snippet ? `Snippet: ${snippet}` : ""),
113119
);
114120
}

0 commit comments

Comments
 (0)