Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a1f4aa1
Fix OpenAI WebSocket error decoding and preserve provider details (#1…
tim-smart Nov 15, 2026
1b807a0
Fix LayerRef error inference when preload is omitted (#10646)
tim-smart Nov 15, 2026
277161b
Add effect/encoding/Thrift
fubhy Nov 15, 2026
b66db22
Focus Thrift tests and shrink the gold fixture
effect-bot Nov 15, 2026
3166345
Validate Thrift reader limits and writer initialSize
effect-bot Nov 15, 2026
d7ba781
Keep a leading byte order mark in Thrift strings
effect-bot Nov 15, 2026
cad41c3
Reject out-of-range Thrift i16 values and field ids
effect-bot Nov 15, 2026
638455e
Rethrow Thrift usage errors from decode
effect-bot Nov 15, 2026
96843ae
Forget a pending Thrift bool field when the reader moves
effect-bot Nov 15, 2026
de2c368
Reject Thrift values of no type in writeValue
effect-bot Nov 15, 2026
f782195
Share Thrift header code and check limits before the input size
effect-bot Nov 15, 2026
81999f3
Rename Thrift Options to ReaderOptions
effect-bot Nov 15, 2026
9c8ed80
Document Thrift view lifetimes, option validation and stack depth
effect-bot Nov 15, 2026
ac8909e
Shorten the Thrift changeset
effect-bot Nov 15, 2026
9a3b076
Keep BOMs in the Thrift string round-trip oracle
effect-bot Nov 15, 2026
d43d38b
Cap Thrift maxDepth at 1000 so recursive reads stay within the stack
effect-bot Nov 15, 2026
997f399
Simplify Thrift internals
effect-bot Nov 15, 2026
81b9a19
Simplify Thrift tests and fixture generator
effect-bot Nov 15, 2026
0c97830
Add effect/encoding/Parquet reader
effect-bot Nov 15, 2026
a4c9715
Cap fixed-width and per-page value allocations, fix spec references
effect-bot Nov 15, 2026
3ebf8d1
Simplify Parquet reader and tests
effect-bot Nov 15, 2026
c789f79
Reject a negative num_values in column chunk metadata
effect-bot Nov 16, 2026
cf57dc8
Reject unknown and missing time units and ignore the order of unknown…
effect-bot Nov 16, 2026
323e9e1
Check annotations against the physical type and parameters the spec d…
effect-bot Nov 16, 2026
af329cd
Reject STRING, ENUM and JSON values that are not UTF-8
effect-bot Nov 16, 2026
300b34c
Check pages against the CRC in their header
effect-bot Nov 16, 2026
492b33b
Simplify the DECIMAL precision check
effect-bot Nov 16, 2026
13df748
Share the CRC-32 file with the compression branch verbatim
effect-bot Nov 16, 2026
e179505
Say that statistics have no known order when the column order is unde…
effect-bot Nov 16, 2026
c712410
Merge feat/arrow-support into feat/encoding-parquet
effect-bot Nov 16, 2026
126a31f
Ignore the converted type of a node whose logical type is ignored, an…
effect-bot Nov 16, 2026
2696361
Merge feat/arrow-support into feat/encoding-parquet
effect-bot Nov 16, 2026
862fc62
Keep the converted type to logical type table in one place and return…
effect-bot Nov 16, 2026
0d758b5
Correct the module doc on unknown converted types and tighten the pag…
effect-bot Nov 16, 2026
c06994c
Merge feat/arrow-support into feat/encoding-parquet
effect-bot Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/encoding-parquet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Add the experimental `effect/encoding/Parquet` module, which reads Apache Parquet metadata and column chunks into Arrow-style buffers.
5 changes: 5 additions & 0 deletions .changeset/encoding-thrift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Add the experimental `effect/encoding/Thrift` module, which reads and writes the Apache Thrift compact protocol without an IDL.
5 changes: 5 additions & 0 deletions .changeset/fix-layer-ref-preload-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Fix `LayerRef.make` and `LayerRef.Service` exposing layer build errors during creation when `preload` is omitted.
5 changes: 5 additions & 0 deletions .changeset/openai-websocket-error-details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/ai-openai": patch
---

Fix OpenAI WebSocket streams hanging on errors with missing messages or nullable type/code fields, and preserve provider error details.
2 changes: 2 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"**/CHANGELOG.md",
"packages/effect/src/StandardSchema.ts",
"packages/tools/graphql-generator/test/generated/**/*.graphql.ts",
"packages/effect/test/fixtures/thrift/gold.json",
"packages/effect/test/fixtures/parquet/gold.json",
"!scratchpad/**/*",
"**/.*",
"!.agents",
Expand Down
21 changes: 12 additions & 9 deletions packages/ai/openai/src/OpenAiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,12 @@ const makeSocket = Effect.gen(function*() {
if (event.type === "error") {
const status = "status" in event ? Number(event.status) : NaN
const error = ("error" in event ? event.error : event) as {
readonly type?: string
readonly code?: string
readonly message: string
readonly type?: string | null
readonly code?: string | null
readonly message?: string
}
const errorType = error.code ??
(error.type === "api_error" && /^gRPC error: Response with id=\S+ not found$/.test(error.message)
(error.type === "api_error" && /^gRPC error: Response with id=\S+ not found$/.test(error.message ?? "")
? "previous_response_not_found"
: error.type ?? "unknown")
const json = JSON.stringify(error)
Expand Down Expand Up @@ -736,11 +736,14 @@ const ErrorEvent = Schema.Struct({
),
status: Schema.optionalKey(Schema.Int),
// xAI sends `code` in place of `type`, e.g. `previous_response_not_found`
error: Schema.Struct({
type: Schema.optional(Schema.String),
code: Schema.optional(Schema.String),
message: Schema.String
})
error: Schema.StructWithRest(
Schema.Struct({
type: Schema.optionalKey(Schema.NullOr(Schema.String)),
code: Schema.optionalKey(Schema.NullOr(Schema.String)),
message: Schema.optionalKey(Schema.String)
}),
[Schema.Record(Schema.String, Schema.Unknown)]
)
})

const errorTypeToStatus: Record<string, number> = {
Expand Down
65 changes: 65 additions & 0 deletions packages/ai/openai/test/OpenAiClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,63 @@ describe("OpenAiClient", () => {
})

describe("createResponseStream", () => {
it.effect("preserves the HTTP usage-limit error body", () =>
Effect.gen(function*() {
const client = yield* OpenAiClient.OpenAiClient
const result = yield* client.createResponseStream({ model: "gpt-4o", input: "test" }).pipe(Effect.flip)
assert.strictEqual(result.reason._tag, "RateLimitError")
if (result.reason._tag !== "RateLimitError") return
assert.deepStrictEqual(JSON.parse(result.reason.http!.body!), { error: usageLimitError })
}).pipe(Effect.provide(makeTestLayer(undefined, {
_tag: "Json",
status: 429,
body: { error: usageLimitError }
}))))

it.live.each([
{ name: "explicit status", status: 429, error: usageLimitError, reason: "RateLimitError" },
{ name: "no status", error: usageLimitError, reason: "InternalProviderError" },
{
name: "no message",
status: 429,
error: { type: "usage_limit_reached", plan_type: "pro" },
reason: "RateLimitError"
},
{ name: "null code", status: 429, error: { ...usageLimitError, code: null }, reason: "RateLimitError" },
{ name: "null type", status: 429, error: { ...usageLimitError, type: null }, reason: "RateLimitError" },
{ name: "mapped type", error: { ...usageLimitError, type: "rate_limit_error" }, reason: "RateLimitError" },
{ name: "api error without message", error: { type: "api_error" }, reason: "InternalProviderError" }
])("preserves WebSocket error details with $name", (frame) =>
Effect.gen(function*() {
const server = yield* Effect.acquireRelease(
Effect.sync(() =>
new WS(`wss://errors.test/${encodeURIComponent(frame.name)}/responses`, { jsonProtocol: true })
),
(server) => Effect.sync(() => server.close())
)
yield* OpenAiClient.withWebSocketMode(
Effect.gen(function*() {
const client = yield* OpenAiClient.OpenAiClient
const [, stream] = yield* client.createResponseStream({ model: "gpt-4o", input: "test" })
const [result] = yield* Effect.all([
Stream.runDrain(stream).pipe(Effect.flip),
nextWebSocketCreate(server).pipe(
Effect.tap(() => Effect.sync(() => server.send({ type: "error", ...frame })))
)
], { concurrency: "unbounded" })
assert.strictEqual(result._tag, "AiError")
assert.strictEqual(result.reason._tag, frame.reason)
if (result.reason._tag !== "RateLimitError" && result.reason._tag !== "InternalProviderError") return
assert.deepStrictEqual(result.reason.metadata, frame.error)
assert.deepStrictEqual(JSON.parse(result.reason.http!.body!), frame.error)
})
).pipe(
Effect.provide(makeTestLayer({ apiUrl: `https://errors.test/${encodeURIComponent(frame.name)}` })),
Effect.provideService(Socket.WebSocketConstructor, (url) => new globalThis.WebSocket(url)),
Effect.timeout("1 second")
)
}))

it.effect("emits response.completed before [DONE] in the same SSE chunk", () =>
Effect.gen(function*() {
const client = yield* OpenAiClient.OpenAiClient
Expand Down Expand Up @@ -1376,3 +1433,11 @@ const makeResponse = (
}
})
}

const usageLimitError = {
type: "usage_limit_reached",
message: "Usage limit reached",
resets_at: 1800000000,
plan_type: "pro",
limit_window_minutes: 300
}
4 changes: 2 additions & 2 deletions packages/effect/src/LayerRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface LayerRef<in out I, in out E = never> {
* @since 4.0.0
*/
export const make = Effect.fnUntraced(
function*<I, E, R, X, const Preload extends boolean = never, SE = never, SR = never>(
function*<I, E, R, X, const Preload extends boolean = false, SE = never, SR = never>(
layer: Layer.Layer<I, E, R>,
options?: {
/**
Expand Down Expand Up @@ -317,7 +317,7 @@ export const Service = <Self>() =>
R,
X,
const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [],
const Preload extends boolean = never,
const Preload extends boolean = false,
SE = never,
SR = never
>(
Expand Down
Loading