Skip to content

Commit 8c76390

Browse files
fix: the opt-out probe parses a whitespace-only source, as the loader does
Only an empty source is skipped; whitespace goes to the parser and fails, so the read is unreadable. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X
1 parent 78babdd commit 8c76390

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎packages/opencode/src/altimate/telemetry/config-state.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function disabledState(directory: string = process.cwd()): Promise<
5959
// Parse as the loader does (a missing `{file:}` reference is an error) and validate with the
6060
// loader's own schema step, so a source Config would reject cannot set the answer.
6161
const parse = async (text: string, input: string | { source: string; dir: string }) => {
62-
if (!text.trim()) return // the loader treats an empty file as `{}`
62+
if (!text) return // the loader skips only an empty file; whitespace still goes to its parser
6363
const source = typeof input === "string" ? input : input.source
6464
try {
6565
take(validateLoaded(await ConfigPaths.parseText(text, input, "error", { track: false }), source))

‎packages/opencode/test/altimate/telemetry/config-state.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ describe("TelemetryConfig.disabledState (no Instance)", () => {
8484
expect(await TelemetryConfig.disabledState(dir)).toBe("unreadable")
8585
})
8686

87+
test("an empty source is skipped but a whitespace-only one is unreadable, as in the loader", async () => {
88+
writeFileSync(globalFile(), "")
89+
expect(await TelemetryConfig.disabledState(dir)).toBe("enabled")
90+
process.env.OPENCODE_CONFIG_CONTENT = " "
91+
expect(await TelemetryConfig.disabledState(dir)).toBe("unreadable")
92+
delete process.env.OPENCODE_CONFIG_CONTENT
93+
writeFileSync(globalFile(), " \n")
94+
expect(await TelemetryConfig.disabledState(dir)).toBe("unreadable")
95+
})
96+
8797
test("nothing sets it: enabled", async () => {
8898
expect(await TelemetryConfig.disabledState(dir)).toBe("enabled")
8999
})

0 commit comments

Comments
 (0)