fix(doctor): preserve built-in channel plugin allow entries

This commit is contained in:
Peter Steinberger
2026-05-02 15:26:52 +01:00
parent bf2711b40e
commit 75dd28e083
2 changed files with 35 additions and 2 deletions

View File

@@ -114,6 +114,39 @@ describe("doctor stale plugin config helpers", () => {
]);
});
it("keeps built-in channel ids in restrictive plugin config", () => {
const result = maybeRepairStalePluginConfig({
plugins: {
allow: ["telegram", "whatsapp", "acpx"],
entries: {
telegram: { enabled: true },
whatsapp: { enabled: true },
acpx: { enabled: true },
},
},
channels: {
whatsapp: {
enabled: true,
allowFrom: ["+15555550123"],
},
},
} as OpenClawConfig);
expect(result.changes).toEqual([
"- plugins.allow: removed 1 stale plugin id (acpx)",
"- plugins.entries: removed 1 stale plugin entry (acpx)",
]);
expect(result.config.plugins?.allow).toEqual(["telegram", "whatsapp"]);
expect(result.config.plugins?.entries).toEqual({
telegram: { enabled: true },
whatsapp: { enabled: true },
});
expect(result.config.channels?.whatsapp).toEqual({
enabled: true,
allowFrom: ["+15555550123"],
});
});
it("removes stale third-party channel config and dependent channel refs", () => {
const result = maybeRepairStalePluginConfig({
plugins: {

View File

@@ -104,7 +104,7 @@ function scanStalePluginConfigWithState(
continue;
}
const pluginId = normalizePluginId(rawPluginId);
if (!pluginId || knownIds.has(pluginId)) {
if (!pluginId || knownIds.has(pluginId) || registryState.knownChannelIds.has(pluginId)) {
continue;
}
hits.push({
@@ -119,7 +119,7 @@ function scanStalePluginConfigWithState(
if (entries) {
for (const rawPluginId of Object.keys(entries)) {
const pluginId = normalizePluginId(rawPluginId);
if (!pluginId || knownIds.has(pluginId)) {
if (!pluginId || knownIds.has(pluginId) || registryState.knownChannelIds.has(pluginId)) {
continue;
}
hits.push({