fix: tolerate bundled channel catalog discovery failures

This commit is contained in:
Peter Steinberger
2026-05-02 02:37:12 +01:00
parent 8a5f08ee13
commit 9b13616240
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
import { afterEach, describe, expect, it, vi } from "vitest";
afterEach(() => {
vi.restoreAllMocks();
vi.resetModules();
});
describe("listBundledChannelCatalogEntries discovery failures", () => {
it("falls back when bundled plugin catalog discovery is unavailable during import", async () => {
vi.doMock("../infra/openclaw-root.js", () => ({
resolveOpenClawPackageRootSync: () => null,
resolveOpenClawPackageRoot: async () => null,
}));
vi.doMock("../plugins/channel-catalog-registry.js", () => ({
listChannelCatalogEntries() {
throw new ReferenceError("Cannot access 'discoverOpenClawPlugins' before initialization.");
},
}));
const catalog = await importFreshModule<typeof import("./bundled-channel-catalog-read.js")>(
import.meta.url,
"./bundled-channel-catalog-read.js?scope=discovery-fail-soft",
);
expect(catalog.listBundledChannelCatalogEntries()).toEqual([]);
});
});

View File

@@ -28,7 +28,11 @@ function listPackageRoots(): string[] {
}
function readBundledExtensionCatalogEntriesSync(): PluginPackageChannel[] {
return listChannelCatalogEntries({ origin: "bundled" }).map((entry) => entry.channel);
try {
return listChannelCatalogEntries({ origin: "bundled" }).map((entry) => entry.channel);
} catch {
return [];
}
}
function readOfficialCatalogFileSync(): ChannelCatalogEntryLike[] {