From dba1d4c705546ceb81db931c316d290c41c657fd Mon Sep 17 00:00:00 2001 From: damaozi <1811866786@qq.com> Date: Fri, 13 Feb 2026 15:13:38 +0800 Subject: [PATCH] fix(config): accept $schema key in root config (#14998) --- CHANGELOG.md | 1 + src/config/config.schema-key.test.ts | 21 +++++++++++++++++++++ src/config/zod-schema.ts | 1 + 3 files changed, 23 insertions(+) create mode 100644 src/config/config.schema-key.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4fe623545..2cd3e6abe38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Docs: https://docs.openclaw.ai - Config: keep legacy audio transcription migration strict by rejecting non-string/unsafe command tokens while still migrating valid custom script executables. (#5042) Thanks @shayan919293. - Status/Sessions: stop clamping derived `totalTokens` to context-window size, keep prompt-token snapshots wired through session accounting, and surface context usage as unknown when fresh snapshot data is missing to avoid false 100% reports. (#15114) Thanks @echoVic. - Providers/MiniMax: switch implicit MiniMax API-key provider from `openai-completions` to `anthropic-messages` with the correct Anthropic-compatible base URL, fixing `invalid role: developer (2013)` errors on MiniMax M2.5. (#15275) Thanks @lailoo. +- Config: accept `$schema` key in config file so JSON Schema editor tooling works without validation errors. (#14998) ## 2026.2.12 diff --git a/src/config/config.schema-key.test.ts b/src/config/config.schema-key.test.ts new file mode 100644 index 00000000000..50bb359eb7c --- /dev/null +++ b/src/config/config.schema-key.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from "vitest"; +import { OpenClawSchema } from "./zod-schema.js"; + +describe("$schema key in config (#14998)", () => { + it("accepts config with $schema string", () => { + const result = OpenClawSchema.safeParse({ + $schema: "https://openclaw.ai/config.json", + }); + expect(result.success).toBe(true); + }); + + it("accepts config without $schema", () => { + const result = OpenClawSchema.safeParse({}); + expect(result.success).toBe(true); + }); + + it("rejects non-string $schema", () => { + const result = OpenClawSchema.safeParse({ $schema: 123 }); + expect(result.success).toBe(false); + }); +}); diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index d5289c34cb5..517ec16de24 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -95,6 +95,7 @@ const MemorySchema = z export const OpenClawSchema = z .object({ + $schema: z.string().optional(), meta: z .object({ lastTouchedVersion: z.string().optional(),