fix: sanitize stale nested plugin paths in plugins.load.paths (#608)
Co-authored-by: Kagura Chen <daniyuu19@sjtu.edu.cn>
This commit is contained in:
committed by
GitHub
Unverified
parent
5836ba6b13
commit
e10ff3a1fb
@@ -1039,6 +1039,28 @@ export async function sanitizeOpenClawConfig(): Promise<void> {
|
||||
}
|
||||
}
|
||||
if (modified) pluginsObj.load = validLoad;
|
||||
} else if (pluginsObj.load && typeof pluginsObj.load === 'object' && !Array.isArray(pluginsObj.load)) {
|
||||
// Handle nested shape: plugins.load.paths (array of absolute paths)
|
||||
const loadObj = pluginsObj.load as Record<string, unknown>;
|
||||
if (Array.isArray(loadObj.paths)) {
|
||||
const validPaths: unknown[] = [];
|
||||
const countBefore = loadObj.paths.length;
|
||||
for (const p of loadObj.paths) {
|
||||
if (typeof p === 'string' && p.startsWith('/')) {
|
||||
if (p.includes('node_modules/openclaw/extensions') || !(await fileExists(p))) {
|
||||
console.log(`[sanitize] Removing stale/bundled plugin path "${p}" from plugins.load.paths`);
|
||||
modified = true;
|
||||
} else {
|
||||
validPaths.push(p);
|
||||
}
|
||||
} else {
|
||||
validPaths.push(p);
|
||||
}
|
||||
}
|
||||
if (validPaths.length !== countBefore) {
|
||||
loadObj.paths = validPaths;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user