Skip to content

Commit c963d4c

Browse files
committed
fix(opencode): recognize status code authentication errors
1 parent b88ff41 commit c963d4c

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/provider-opencode/src/server/status.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ it.layer(layerTest)("checkOpenCodeProviderStatus with configured server URL", (i
810810
"status=403 body={}",
811811
"HTTP 401",
812812
"HTTP/1.1 403",
813+
"Response status code: 401",
814+
"Response status code: 403",
815+
"Request failed with status code 401",
816+
"Request failed with status code 403",
813817
])("keeps explicit authentication rejection actionable: %s", (detail) =>
814818
Effect.gen(function* () {
815819
runtimeMock.state.connectionError = new Error(detail);

‎packages/provider-opencode/src/server/status.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ function formatOpenCodeProbeError(input: {
7777
if (input.isExternalServer) {
7878
// Bare auth-code digits can be part of the endpoint's port or path.
7979
if (
80-
/(?:^|\s)(?:status[=:]\s*|http(?:\/\d(?:\.\d)?)?\s+)(?:401|403)\b/.test(lower) ||
80+
/(?:^|\s)(?:status(?:\s+code)?(?:\s*[:=]\s*|\s+)|http(?:\/\d(?:\.\d)?)?\s+)(?:401|403)\b/.test(
81+
lower,
82+
) ||
8183
/\b(?:unauthorized|forbidden)\b/.test(lower)
8284
) {
8385
return {

0 commit comments

Comments
 (0)