From 74aa8ddea56d2fb55f6e317087c986b657604c39 Mon Sep 17 00:00:00 2001 From: Helge Tesdal Date: Thu, 23 Apr 2026 22:10:25 +0200 Subject: [PATCH] fix(config): remove duplicate description annotation on timeout/chunkTimeout The inner Union schema already carried the description. The outer Schema.optional annotation re-applied it, producing duplicate entries in SDK codegen output. Collapses to a single annotation. Regression test: test/config/provider-schema.test.ts asserts each description substring appears exactly once in the schema AST. Addresses audit finding F1 (Opus diamond review, 2026-04-22). --- packages/opencode/src/config/provider.ts | 10 ++-------- .../test/config/provider-schema.test.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 packages/opencode/test/config/provider-schema.test.ts diff --git a/packages/opencode/src/config/provider.ts b/packages/opencode/src/config/provider.ts index ae4f4b9b5454..a0412663f7fa 100644 --- a/packages/opencode/src/config/provider.ts +++ b/packages/opencode/src/config/provider.ts @@ -94,19 +94,13 @@ export const Info = Schema.Struct({ description: "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.", }), - ).annotate({ - description: - "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.", - }), + ), chunkTimeout: Schema.optional( Schema.Union([PositiveInt, Schema.Literal(false)]).annotate({ description: "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted. Defaults to 120000 (120s) for most providers, 600000 (10min) for Anthropic-family providers (to accommodate extended thinking). Set to false to disable.", }), - ).annotate({ - description: - "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted. Defaults to 120000 (120s) for most providers, 600000 (10min) for Anthropic-family providers (to accommodate extended thinking). Set to false to disable.", - }), + ), }), [Schema.Record(Schema.String, Schema.Any)], ), diff --git a/packages/opencode/test/config/provider-schema.test.ts b/packages/opencode/test/config/provider-schema.test.ts new file mode 100644 index 000000000000..f9efba6938a7 --- /dev/null +++ b/packages/opencode/test/config/provider-schema.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, test } from "bun:test" +import { ConfigProvider } from "../../src/config/provider" + +describe("ConfigProvider schema", () => { + test("chunkTimeout has exactly one description annotation", () => { + const json = JSON.stringify(ConfigProvider.Info.ast) + const needle = "Timeout in milliseconds between streamed SSE chunks" + const count = json.split(needle).length - 1 + expect(count).toBe(1) + }) + + test("timeout has exactly one description annotation", () => { + const json = JSON.stringify(ConfigProvider.Info.ast) + const needle = "Timeout in milliseconds for requests to this provider" + const count = json.split(needle).length - 1 + expect(count).toBe(1) + }) +})