fix(plugins): quiet trusted discovery warning (#104097)

This commit is contained in:
Peter Steinberger
2026-07-10 19:53:03 -07:00
committed by GitHub
parent bb26753705
commit 2cc8bb40fd
3 changed files with 36 additions and 1 deletions

View File

@@ -220,6 +220,7 @@ export function warnWhenAllowlistIsOpen(params: {
allow: string[];
warningCacheKey: string;
warningCache: OpenAllowlistWarningCache;
explicitlyEnabledPluginIds?: ReadonlySet<string>;
discoverablePlugins: Array<{ id: string; source: string; origin: PluginRecord["origin"] }>;
}) {
if (!params.emitWarning) {
@@ -229,7 +230,9 @@ export function warnWhenAllowlistIsOpen(params: {
return;
}
const autoDiscoverable = params.discoverablePlugins.filter(
(entry) => entry.origin === "workspace" || entry.origin === "global",
(entry) =>
(entry.origin === "workspace" || entry.origin === "global") &&
!params.explicitlyEnabledPluginIds?.has(entry.id),
);
if (autoDiscoverable.length === 0) {
return;

View File

@@ -8794,6 +8794,28 @@ module.exports = {
});
});
it("stays quiet when every non-bundled plugin is explicitly enabled", () => {
useNoBundledPlugins();
clearPluginLoaderCache();
const { workspaceDir } = writeWorkspacePlugin({
id: "warn-explicitly-enabled-plugin",
});
const warnings: string[] = [];
loadOpenClawPlugins({
cache: false,
workspaceDir,
logger: createWarningLogger(warnings),
config: {
plugins: {
enabled: true,
entries: { "warn-explicitly-enabled-plugin": { enabled: true } },
},
},
});
expect(warnings.join("\n")).not.toContain("plugins.allow is empty");
});
it("warns when plugins.allow entries do not match any discovered plugin ids", () => {
useNoBundledPlugins();
clearPluginLoaderCache();

View File

@@ -2049,6 +2049,11 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
allow: normalized.allow,
warningCacheKey: cacheKey,
warningCache: pluginLoaderCacheState,
explicitlyEnabledPluginIds: new Set(
Object.entries(normalized.entries)
.filter(([, entry]) => entry.enabled === true)
.map(([pluginId]) => pluginId),
),
// Keep warning input scoped as well so partial snapshot loads only mention the
// plugins that were intentionally requested for this registry.
discoverablePlugins: manifestRegistry.plugins
@@ -3039,6 +3044,11 @@ export async function loadOpenClawPluginCliRegistry(
allow: normalized.allow,
warningCacheKey: `${cacheKey}::cli-metadata`,
warningCache: pluginLoaderCacheState,
explicitlyEnabledPluginIds: new Set(
Object.entries(normalized.entries)
.filter(([, entry]) => entry.enabled === true)
.map(([pluginId]) => pluginId),
),
discoverablePlugins: manifestRegistry.plugins
.filter((plugin) => !onlyPluginIdSet || onlyPluginIdSet.has(plugin.id))
.map((plugin) => ({