mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
fix(plugins): reject malformed channel registrations
This commit is contained in:
@@ -241,6 +241,7 @@ function assertInstalled() {
|
||||
|
||||
const expectedErrorMessages = new Set([
|
||||
"only bundled plugins can register agent tool result middleware",
|
||||
'channel "kitchen-sink-channel-probe" registration missing required config helpers',
|
||||
"cli registration missing explicit commands metadata",
|
||||
"only bundled plugins can register Codex app-server extension factories",
|
||||
"http route registration missing or invalid auth: /kitchen-sink/http-route",
|
||||
|
||||
@@ -114,4 +114,26 @@ describe("normalizeRegisteredChannelPlugin", () => {
|
||||
'channel "demo" meta.id mismatch ("other-demo"); using registered channel id',
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects runtime channel registrations without required config helpers", () => {
|
||||
const { diagnostics, pushDiagnostic } = collectDiagnostics();
|
||||
|
||||
const normalized = normalizeRegisteredChannelPlugin({
|
||||
pluginId: "demo-plugin",
|
||||
source: "/tmp/demo/index.ts",
|
||||
plugin: createChannelPlugin({
|
||||
id: "broken-channel",
|
||||
config: undefined as never,
|
||||
}),
|
||||
pushDiagnostic,
|
||||
});
|
||||
|
||||
expect(normalized).toBeNull();
|
||||
expect(diagnostics).toEqual([
|
||||
expect.objectContaining({
|
||||
level: "error",
|
||||
message: 'channel "broken-channel" registration missing required config helpers',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,6 +50,19 @@ export function normalizeRegisteredChannelPlugin(params: {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
typeof params.plugin.config?.listAccountIds !== "function" ||
|
||||
typeof params.plugin.config?.resolveAccount !== "function"
|
||||
) {
|
||||
pushPluginValidationDiagnostic({
|
||||
level: "error",
|
||||
pluginId: params.pluginId,
|
||||
source: params.source,
|
||||
message: `channel "${id}" registration missing required config helpers`,
|
||||
pushDiagnostic: params.pushDiagnostic,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
const rawMeta = params.plugin.meta as Partial<ChannelMeta> | undefined;
|
||||
const rawMetaId = normalizeOptionalString(rawMeta?.id);
|
||||
|
||||
Reference in New Issue
Block a user