fix(core): surface authorization cause in error message (#49214)

This commit is contained in:
Aiden Cline
2026-09-15 14:38:15 -05:00
committed by GitHub
Unverified
parent 6c9115eb75
commit e31ad14c1d
2 changed files with 21 additions and 2 deletions
+7 -1
View File
@@ -111,7 +111,13 @@ export class CodeRequiredError extends Schema.TaggedError<CodeRequiredError>()("
export class AuthorizationError extends Schema.TaggedError<AuthorizationError>()("Integration.Authorization", {
cause: Schema.Defect(),
}) {}
}) {
override get message() {
const cause = this.cause
if (cause instanceof Error && cause.message) return cause.message
return "Authorization failed"
}
}
export class AttemptNotFoundError extends Schema.TaggedError<AttemptNotFoundError>()("Integration.AttemptNotFound", {
integrationID: ID,
+14 -1
View File
@@ -1,4 +1,4 @@
import { describe, expect } from "bun:test"
import { describe, expect, test } from "bun:test"
import { Cause, Clock, Duration, Effect, Exit, Fiber, Layer, Scope, Stream } from "effect"
import { TestClock } from "effect/testing"
import { Credential } from "@opencode/core/credential"
@@ -674,3 +674,16 @@ describe("Integration", () => {
)
})
})
describe("AuthorizationError", () => {
test("reports the underlying cause message", () => {
expect(new Integration.AuthorizationError({ cause: new Error("Request failed: 401") }).message).toBe(
"Request failed: 401",
)
})
test("falls back when the cause carries no message", () => {
expect(new Integration.AuthorizationError({ cause: new Error() }).message).toBe("Authorization failed")
expect(new Integration.AuthorizationError({ cause: undefined }).message).toBe("Authorization failed")
})
})