Compare commits

..

1 Commits

Author SHA1 Message Date
opencode 474abdd7ee release: v1.17.17 2026-07-09 15:02:58 +00:00
2 changed files with 6 additions and 34 deletions
+4 -16
View File
@@ -195,33 +195,21 @@ const layer: Layer.Layer<Service, never, AccountRepo.Service | HttpClient.HttpCl
const httpOk = HttpClient.filterStatusOk(http)
const httpReadOk = HttpClient.filterStatusOk(httpRead)
const executeRequest = <A, E, R>(request: HttpClientRequest.HttpClientRequest, effect: Effect.Effect<A, E, R>) =>
Effect.logDebug("account request").pipe(
Effect.annotateLogs({ method: request.method, url: request.url }),
Effect.andThen(effect),
mapAccountServiceError("HTTP request failed"),
Effect.tapError((error) =>
Effect.logError("account request failed").pipe(
Effect.annotateLogs({ method: request.method, url: request.url, error: error.message }),
),
),
)
const executeRead = (request: HttpClientRequest.HttpClientRequest) =>
executeRequest(request, httpRead.execute(request))
httpRead.execute(request).pipe(mapAccountServiceError("HTTP request failed"))
const executeReadOk = (request: HttpClientRequest.HttpClientRequest) =>
executeRequest(request, httpReadOk.execute(request))
httpReadOk.execute(request).pipe(mapAccountServiceError("HTTP request failed"))
const executeEffectOk = <E>(request: Effect.Effect<HttpClientRequest.HttpClientRequest, E>) =>
request.pipe(
Effect.flatMap((req) => executeRequest(req, httpOk.execute(req))),
Effect.flatMap((req) => httpOk.execute(req)),
mapAccountServiceError("HTTP request failed"),
)
const executeEffect = <E>(request: Effect.Effect<HttpClientRequest.HttpClientRequest, E>) =>
request.pipe(
Effect.flatMap((req) => executeRequest(req, http.execute(req))),
Effect.flatMap((req) => http.execute(req)),
mapAccountServiceError("HTTP request failed"),
)
+2 -18
View File
@@ -1,7 +1,7 @@
import { expect } from "bun:test"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { httpClient } from "@opencode-ai/core/effect/app-node-platform"
import { Duration, Effect, Layer, Logger, Option, References, Schema } from "effect"
import { Duration, Effect, Layer, Option, Schema } from "effect"
import { sql } from "drizzle-orm"
import { HttpClient, HttpClientError, HttpClientResponse } from "effect/unstable/http"
@@ -102,8 +102,6 @@ it.live("login normalizes trailing slashes in the provided server URL", () =>
it.live("login maps transport failures to account transport errors", () =>
Effect.gen(function* () {
const logs: Array<string> = []
const logger = Logger.formatLogFmt.pipe(Logger.map((output) => logs.push(output)))
const client = HttpClient.make((req) =>
Effect.fail(
new HttpClientError.HttpClientError({
@@ -112,27 +110,13 @@ it.live("login maps transport failures to account transport errors", () =>
),
)
const error = yield* Effect.flip(
Account.use
.login("https://one.example.com")
.pipe(
Effect.provide(live(client)),
Effect.provide(Logger.layer([logger])),
Effect.provideService(References.MinimumLogLevel, "Debug"),
),
)
const error = yield* Effect.flip(Account.use.login("https://one.example.com").pipe(Effect.provide(live(client))))
expect(error).toBeInstanceOf(AccountTransportError)
if (error instanceof AccountTransportError) {
expect(error.method).toBe("POST")
expect(error.url).toBe("https://one.example.com/auth/device/code")
}
expect(logs).toHaveLength(2)
expect(logs[0]).toContain('message="account request"')
expect(logs[0]).toContain("method=POST")
expect(logs[0]).toContain("url=https://one.example.com/auth/device/code")
expect(logs[1]).toContain('message="account request failed"')
expect(logs.join("\n")).not.toContain("opencode-cli")
}),
)