fix(validation): preserve null in anyOf unions instead of coercing to… · openclaw/openclaw@361869e
zw-xysk
·
2026-06-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -39,4 +39,29 @@ describe("validateToolArguments", () => {
|
39 | 39 | }), |
40 | 40 | ).toThrow(/Validation failed for tool "decimal-tool"/); |
41 | 41 | }); |
| 42 | + |
| 43 | +it("preserves null in anyOf [{type: string}, {type: null}] without coercing to empty string (#96716)", () => { |
| 44 | +const tool = { |
| 45 | +name: "nullable-tool", |
| 46 | +description: "test tool", |
| 47 | +parameters: { |
| 48 | +type: "object", |
| 49 | +properties: { |
| 50 | +insight_id: { anyOf: [{ type: "string" }, { type: "null" }] }, |
| 51 | +cluster_name: { type: "string" }, |
| 52 | +}, |
| 53 | +required: ["cluster_name"], |
| 54 | +additionalProperties: false, |
| 55 | +}, |
| 56 | +} as Tool; |
| 57 | + |
| 58 | +expect( |
| 59 | +validateToolArguments(tool, { |
| 60 | +type: "toolCall", |
| 61 | +id: "call-1", |
| 62 | +name: "nullable-tool", |
| 63 | +arguments: { insight_id: null, cluster_name: "testenv" }, |
| 64 | +}), |
| 65 | +).toEqual({ insight_id: null, cluster_name: "testenv" }); |
| 66 | +}); |
42 | 67 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。