fix: strip $schema via preprocess to avoid spurious UI section

This commit is contained in:
damaozi
2026-02-14 04:06:57 +08:00
parent dba1d4c705
commit 87ed2632d3
2 changed files with 572 additions and 549 deletions

View File

@@ -9,13 +9,23 @@ describe("$schema key in config (#14998)", () => {
expect(result.success).toBe(true);
});
it("strips $schema from parsed output so it does not leak into UI", () => {
const result = OpenClawSchema.safeParse({
$schema: "https://openclaw.ai/config.json",
});
expect(result.success).toBe(true);
if (result.success) {
expect("$schema" in result.data).toBe(false);
}
});
it("accepts config without $schema", () => {
const result = OpenClawSchema.safeParse({});
expect(result.success).toBe(true);
});
it("rejects non-string $schema", () => {
it("ignores non-string $schema (stripped before validation)", () => {
const result = OpenClawSchema.safeParse({ $schema: 123 });
expect(result.success).toBe(false);
expect(result.success).toBe(true);
});
});

File diff suppressed because it is too large Load Diff