fix(plugins): reject malformed channel registrations · openclaw/openclaw@24adf2c
vincentkoc
·
2026-04-29
·
via Recent Commits to openclaw:main
File tree
scripts/e2e/lib/kitchen-sink-plugin
| Original file line number | Diff line number | Diff line change |
|---|
@@ -241,6 +241,7 @@ function assertInstalled() {
|
241 | 241 | |
242 | 242 | const expectedErrorMessages = new Set([ |
243 | 243 | "only bundled plugins can register agent tool result middleware", |
| 244 | +'channel "kitchen-sink-channel-probe" registration missing required config helpers', |
244 | 245 | "cli registration missing explicit commands metadata", |
245 | 246 | "only bundled plugins can register Codex app-server extension factories", |
246 | 247 | "http route registration missing or invalid auth: /kitchen-sink/http-route", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -114,4 +114,26 @@ describe("normalizeRegisteredChannelPlugin", () => {
|
114 | 114 | 'channel "demo" meta.id mismatch ("other-demo"); using registered channel id', |
115 | 115 | ]); |
116 | 116 | }); |
| 117 | + |
| 118 | +it("rejects runtime channel registrations without required config helpers", () => { |
| 119 | +const { diagnostics, pushDiagnostic } = collectDiagnostics(); |
| 120 | + |
| 121 | +const normalized = normalizeRegisteredChannelPlugin({ |
| 122 | +pluginId: "demo-plugin", |
| 123 | +source: "/tmp/demo/index.ts", |
| 124 | +plugin: createChannelPlugin({ |
| 125 | +id: "broken-channel", |
| 126 | +config: undefined as never, |
| 127 | +}), |
| 128 | + pushDiagnostic, |
| 129 | +}); |
| 130 | + |
| 131 | +expect(normalized).toBeNull(); |
| 132 | +expect(diagnostics).toEqual([ |
| 133 | +expect.objectContaining({ |
| 134 | +level: "error", |
| 135 | +message: 'channel "broken-channel" registration missing required config helpers', |
| 136 | +}), |
| 137 | +]); |
| 138 | +}); |
117 | 139 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,19 @@ export function normalizeRegisteredChannelPlugin(params: {
|
50 | 50 | }); |
51 | 51 | return null; |
52 | 52 | } |
| 53 | +if ( |
| 54 | +typeof params.plugin.config?.listAccountIds !== "function" || |
| 55 | +typeof params.plugin.config?.resolveAccount !== "function" |
| 56 | +) { |
| 57 | +pushPluginValidationDiagnostic({ |
| 58 | +level: "error", |
| 59 | +pluginId: params.pluginId, |
| 60 | +source: params.source, |
| 61 | +message: `channel "${id}" registration missing required config helpers`, |
| 62 | +pushDiagnostic: params.pushDiagnostic, |
| 63 | +}); |
| 64 | +return null; |
| 65 | +} |
53 | 66 | |
54 | 67 | const rawMeta = params.plugin.meta as Partial<ChannelMeta> | undefined; |
55 | 68 | const rawMetaId = normalizeOptionalString(rawMeta?.id); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。