Skip to content

Commit c06837f

Browse files
fix(config): preserve empty plugin allowlist
1 parent 846ca1e commit c06837f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/config/plugin-auto-enable.core.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,23 @@ describe("applyPluginAutoEnable core", () => {
289289
expect(result.config.plugins?.allow).toBeUndefined();
290290
});
291291

292+
it("preserves an empty plugins.allow as nonrestrictive during auto-enable", () => {
293+
const result = applyPluginAutoEnable({
294+
config: {
295+
channels: { slack: { botToken: "x" } },
296+
plugins: {
297+
allow: [],
298+
bundledDiscovery: "compat",
299+
},
300+
},
301+
env,
302+
});
303+
304+
expect(result.config.channels?.slack?.enabled).toBe(true);
305+
expect(result.config.plugins?.allow).toEqual([]);
306+
expect(result.changes.join("\n")).toContain("Slack configured, enabled automatically.");
307+
});
308+
292309
it("does not auto-enable Slack from unrelated Slack-prefixed env vars", () => {
293310
const result = applyPluginAutoEnable({
294311
config: {},

src/config/plugin-auto-enable.shared.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ export function materializePluginAutoEnableCandidatesInternal(params: {
10411041
}
10421042

10431043
const allow = next.plugins?.allow;
1044-
const allowMissing = Array.isArray(allow) && !allow.includes(entry.pluginId);
1044+
const hasRestrictiveAllowlist = Array.isArray(allow) && allow.length > 0;
1045+
const allowMissing = hasRestrictiveAllowlist && !allow.includes(entry.pluginId);
10451046
const alreadyEnabled =
10461047
builtInChannelId != null
10471048
? isBuiltInChannelAlreadyEnabled(next, builtInChannelId)
@@ -1051,7 +1052,9 @@ export function materializePluginAutoEnableCandidatesInternal(params: {
10511052
}
10521053

10531054
next = registerPluginEntry(next, entry, params.manifestRegistry);
1054-
next = ensurePluginAllowlisted(next, entry.pluginId);
1055+
if (hasRestrictiveAllowlist) {
1056+
next = ensurePluginAllowlisted(next, entry.pluginId);
1057+
}
10551058
const reason = resolvePluginAutoEnableCandidateReason(entry);
10561059
autoEnabledReasons.set(entry.pluginId, [
10571060
...(autoEnabledReasons.get(entry.pluginId) ?? []),

0 commit comments

Comments
 (0)