fix(sdk+cli): surface real errors instead of bare {} when server returns empty body (#25592)

This commit is contained in:
Kit Langton
2026-05-03 09:17:06 -04:00
committed by GitHub
parent 7a503de606
commit 379600b5ab
3 changed files with 49 additions and 10 deletions

View File

@@ -22,6 +22,19 @@ describe("util.error", () => {
expect(data.code).toBe("E_BAD")
})
test("never returns bare {} for opaque object errors", () => {
// Plain empty object — what the SDK threw before we wrapped it.
expect(errorFormat({})).not.toBe("{}")
expect(errorFormat({})).toContain("no message")
// Object with only non-enumerable own properties (JSON.stringify drops them).
class OpaqueError {}
const opaque = new OpaqueError()
Object.defineProperty(opaque, "secret", { value: "hidden", enumerable: false })
expect(errorFormat(opaque)).not.toBe("{}")
expect(errorFormat(opaque)).toContain("OpaqueError")
})
test("handles opaque throwables with custom toString", () => {
const err = {
toString() {