fix(opencode): show human-readable message for HTML error responses (#15407)

This commit is contained in:
Rian van der Merwe 2026-03-01 07:24:57 -08:00 committed by GitHub
parent b15fb21191
commit 6b7e6bde4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,6 +76,18 @@ export namespace ProviderError {
}
} catch {}
// If responseBody is HTML (e.g. from a gateway or proxy error page),
// provide a human-readable message instead of dumping raw markup
if (/^\s*<!doctype|^\s*<html/i.test(e.responseBody)) {
if (e.statusCode === 401) {
return "Unauthorized: request was blocked by a gateway or proxy. Your authentication token may be missing or expired — try running `opencode auth login <your provider URL>` to re-authenticate."
}
if (e.statusCode === 403) {
return "Forbidden: request was blocked by a gateway or proxy. You may not have permission to access this resource — check your account and provider settings."
}
return msg
}
return `${msg}: ${e.responseBody}`
}).trim()
}