mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 00:04:07 +00:00
fix(config): preserve large numeric schema keys
This commit is contained in:
@@ -91,6 +91,24 @@ describe("buildJsonChannelConfigSchema", () => {
|
||||
issues: [{ path: ["enabled"], message: "must be boolean" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps numeric-looking object keys outside array-index range as strings", () => {
|
||||
const result = buildJsonChannelConfigSchema(
|
||||
{
|
||||
type: "object",
|
||||
required: ["100001"],
|
||||
properties: {
|
||||
"100001": { type: "boolean" },
|
||||
},
|
||||
},
|
||||
{ cacheKey: "config-schema.test.large-numeric-key-channel" },
|
||||
);
|
||||
|
||||
expect(result.runtime?.safeParse({})).toEqual({
|
||||
success: false,
|
||||
issues: [{ path: ["100001"], message: "must have required property '100001'" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("emptyChannelConfigSchema", () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { z, type ZodRawShape, type ZodTypeAny } from "zod";
|
||||
import { DmPolicySchema } from "../../config/zod-schema.core.js";
|
||||
import { validateJsonSchemaValue } from "../../plugins/schema-validator.js";
|
||||
import type { JsonSchemaObject } from "../../shared/json-schema.types.js";
|
||||
import { parseConfigPathArrayIndex } from "../../shared/path-array-index.js";
|
||||
import type {
|
||||
ChannelConfigRuntimeIssue,
|
||||
ChannelConfigRuntimeParseResult,
|
||||
@@ -84,8 +85,7 @@ function toIssuePath(path: string): Array<string | number> {
|
||||
return [];
|
||||
}
|
||||
return path.split(".").map((segment) => {
|
||||
const index = Number(segment);
|
||||
return Number.isInteger(index) && String(index) === segment ? index : segment;
|
||||
return parseConfigPathArrayIndex(segment) ?? segment;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,26 @@ describe("buildJsonPluginConfigSchema", () => {
|
||||
error: { issues: [{ path: ["enabled"], message: "must be boolean" }] },
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps numeric-looking object keys outside array-index range as strings", () => {
|
||||
const result = buildJsonPluginConfigSchema(
|
||||
{
|
||||
type: "object",
|
||||
required: ["100001"],
|
||||
properties: {
|
||||
"100001": { type: "boolean" },
|
||||
},
|
||||
},
|
||||
{ cacheKey: "config-schema.test.large-numeric-key" },
|
||||
);
|
||||
|
||||
expect(result.safeParse?.({})).toEqual({
|
||||
success: false,
|
||||
error: {
|
||||
issues: [{ path: ["100001"], message: "must have required property '100001'" }],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("emptyPluginConfigSchema", () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z, type ZodTypeAny } from "zod";
|
||||
import type { JsonSchemaObject } from "../shared/json-schema.types.js";
|
||||
import { parseConfigPathArrayIndex } from "../shared/path-array-index.js";
|
||||
import type { PluginConfigUiHint } from "./manifest-types.js";
|
||||
import { validateJsonSchemaValue } from "./schema-validator.js";
|
||||
import type { OpenClawPluginConfigSchema } from "./types.js";
|
||||
@@ -89,8 +90,7 @@ function toIssuePath(path: string): Array<string | number> {
|
||||
return [];
|
||||
}
|
||||
return path.split(".").map((segment) => {
|
||||
const index = Number(segment);
|
||||
return Number.isInteger(index) && String(index) === segment ? index : segment;
|
||||
return parseConfigPathArrayIndex(segment) ?? segment;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user