fix: skip empty channel doctor lookup

This commit is contained in:
Gustavo Madeira Santana
2026-04-21 22:18:24 -04:00
parent 5b1ff1bfe5
commit 120e799a64
2 changed files with 20 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import {
collectChannelDoctorCompatibilityMutations,
collectChannelDoctorEmptyAllowlistExtraWarnings,
collectChannelDoctorStaleConfigMutations,
createChannelDoctorEmptyAllowlistPolicyHooks,
} from "./channel-doctor.js";
@@ -49,6 +50,22 @@ describe("channel doctor compatibility mutations", () => {
expect(mocks.resolveReadOnlyChannelPluginsForConfig).not.toHaveBeenCalled();
});
it("skips plugin discovery when only channel defaults are configured", async () => {
const result = await collectChannelDoctorStaleConfigMutations({
channels: {
defaults: {
enabled: true,
},
},
} as never);
expect(result).toEqual([]);
expect(mocks.resolveReadOnlyChannelPluginsForConfig).not.toHaveBeenCalled();
expect(mocks.getLoadedChannelPlugin).not.toHaveBeenCalled();
expect(mocks.getBundledChannelSetupPlugin).not.toHaveBeenCalled();
expect(mocks.getBundledChannelPlugin).not.toHaveBeenCalled();
});
it("uses read-only doctor adapters for configured channel ids", () => {
const normalizeCompatibilityConfig = vi.fn(({ cfg }: { cfg: unknown }) => ({
config: cfg,

View File

@@ -80,6 +80,9 @@ function listChannelDoctorEntries(
channelIds: readonly string[],
context: ChannelDoctorLookupContext,
): ChannelDoctorEntry[] {
if (channelIds.length === 0) {
return [];
}
const byId = new Map<string, ChannelDoctorEntry>();
const selectedIds = new Set(channelIds);
const readOnlyPlugins = safeListReadOnlyChannelPlugins(context).filter((plugin) =>