Skip to content

Commit e4e61ad

Browse files
committed
fix(opencode): isolate malformed console credentials
1 parent 82a462f commit e4e61ad

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/provider-opencode/src/server/status.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ it.effect("reads Go limits with the instance's XDG credentials and preserves res
9696
);
9797

9898
it.effect(
99-
"uses the selected public Console key for Go limits, falling back only on auth rejection",
99+
"uses the selected public Console credential for Go limits, falling back only on auth rejection",
100100
() =>
101101
Effect.gen(function* () {
102102
const fs = yield* FileSystem.FileSystem;
@@ -195,6 +195,15 @@ it.effect(
195195
{ active: null, requested: ["console-key"] },
196196
// OpenCode 2 uses its stored Go key; auth.json keeps only the stale imported copy.
197197
{ consoleRow: null, storedGo: goRow, requested: ["db-go-key"] },
198+
{
199+
consoleRow: { ...consoleLogin, metadata: { server: "invalid-url" } },
200+
storedGo: goRow,
201+
requested: ["db-go-key"],
202+
},
203+
{
204+
storedGo: { ...goRow, metadata: { server: "invalid-url" } },
205+
requested: ["console-key"],
206+
},
198207
{
199208
consoleRow: null,
200209
storedGo: goRow,

‎packages/provider-opencode/src/server/usageLimits.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const readStoredCredential = (database: NodeSqlite.DatabaseSync, integrationId:
7676
// OpenCode sends a credential without a server string to the public Console,
7777
// and service-account keys never store one.
7878
if (typeof server === "string") {
79-
const url = new URL(server);
80-
if (!PUBLIC_CONSOLE_SERVERS.has(`${url.origin}${url.pathname.replace(/\/+$/, "")}`))
79+
const url = URL.parse(server);
80+
if (!url || !PUBLIC_CONSOLE_SERVERS.has(`${url.origin}${url.pathname.replace(/\/+$/, "")}`))
8181
return undefined;
8282
}
8383
if (stored.type === "key") return { token: stored.key.trim() };

0 commit comments

Comments
 (0)