From c22942c1f38f25b268fc2ff198163243a06177ae Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 10 Aug 2026 12:57:20 -0400 Subject: [PATCH] fix(core): tolerate unavailable wellknown config --- packages/core/src/config.ts | 8 +++++++- packages/core/test/config/config.test.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index d932181be75..1658d9c3abd 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -151,7 +151,13 @@ export const layer = (options?: Options) => ) if (!credential || credential.value.type !== "key") return [] const variables = { [auth.env]: credential.value.key } - const configs = yield* wellknown.resolve(entry, variables).pipe(Effect.orDie) + const configs = yield* wellknown.resolve(entry, variables).pipe( + Effect.catch(() => + Effect.logWarning("failed to load wellknown config", { source: entry.origin }).pipe( + Effect.as([] as const), + ), + ), + ) return yield* Effect.forEach(configs, (config) => ConfigVariable.substitute({ type: "virtual", diff --git a/packages/core/test/config/config.test.ts b/packages/core/test/config/config.test.ts index 346b64517fa..d0e7c7a88e0 100644 --- a/packages/core/test/config/config.test.ts +++ b/packages/core/test/config/config.test.ts @@ -307,7 +307,7 @@ describe("Config", () => { }), ) - it.live("loads authenticated wellknown config before user configuration", () => + it.live("tolerates unavailable authenticated wellknown config and reloads it later", () => Effect.acquireUseRelease( Effect.promise(() => tmpdir()), (tmp) => @@ -322,6 +322,7 @@ describe("Config", () => { }) const integrationID = Integration.ID.make("https://example.com") + let available = false let key = "secret" const credentialNode = makeGlobalNode({ service: Credential.Service, @@ -361,7 +362,10 @@ describe("Config", () => { refresh: () => Effect.succeed(false), add: () => Effect.die("unused Wellknown.add"), remove: () => Effect.die("unused Wellknown.remove"), - resolve: (_entry, variables) => Effect.succeed([{ shell: variables.TOKEN }]), + resolve: (_entry, variables) => + available + ? Effect.succeed([{ shell: variables.TOKEN }]) + : Effect.fail(new Error("expired credential")), }), ), deps: [], @@ -374,11 +378,12 @@ describe("Config", () => { expect(Config.latest(initial, "shell")).toBe("project") expect( initial.flatMap((entry) => (entry.type === "document" && entry.info.shell ? [entry.info.shell] : [])), - ).toEqual(["secret", "global", "project"]) + ).toEqual(["global", "project"]) const updated = yield* bus .subscribe(Event.Updated) .pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped) yield* Effect.yieldNow + available = true key = "next" yield* bus.publish(Integration.Event.ConnectionUpdated, { integrationID }) expect(yield* Fiber.join(updated)).toHaveLength(1)