Skip to content

Commit 04a81ea

Browse files
rianvdmGrappeggia
authored andcommitted
fix(opencode): show human-readable message for HTML error responses (#15407)
1 parent dcad05a commit 04a81ea

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

packages/slopcode/src/provider/error.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ export namespace ProviderError {
7676
}
7777
} catch {}
7878

79+
// If responseBody is HTML (e.g. from a gateway or proxy error page),
80+
// provide a human-readable message instead of dumping raw markup
81+
if (/^\s*<!doctype|^\s*<html/i.test(e.responseBody)) {
82+
if (e.statusCode === 401) {
83+
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."
84+
}
85+
if (e.statusCode === 403) {
86+
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."
87+
}
88+
return msg
89+
}
90+
7991
return `${msg}: ${e.responseBody}`
8092
}).trim()
8193
}

0 commit comments

Comments
 (0)