惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: validate discord component numeric limits · openclaw...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

@@ -62,10 +62,23 @@ function readOptionalStringArray(value: unknown, label: string): string[] | unde

6262

return value.map((entry, index) => readString(entry, `${label}[${index}]`));

6363

}

646465-

function readOptionalNumber(value: unknown): number | undefined {

66-

if (typeof value !== "number" || !Number.isFinite(value)) {

65+

function readOptionalInteger(

66+

value: unknown,

67+

label: string,

68+

bounds?: { min?: number; max?: number },

69+

): number | undefined {

70+

if (value == null) {

6771

return undefined;

6872

}

73+

if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value)) {

74+

throw new Error(`${label} must be an integer`);

75+

}

76+

if (bounds?.min !== undefined && value < bounds.min) {

77+

throw new Error(`${label} must be at least ${bounds.min}`);

78+

}

79+

if (bounds?.max !== undefined && value > bounds.max) {

80+

throw new Error(`${label} must be at most ${bounds.max}`);

81+

}

6982

return value;

7083

}

7184

@@ -197,8 +210,8 @@ function parseSelectSpec(raw: unknown, label: string): DiscordComponentSelectSpe

197210

type,

198211

callbackData: readOptionalString(obj.callbackData),

199212

placeholder: readOptionalString(obj.placeholder),

200-

minValues: readOptionalNumber(obj.minValues),

201-

maxValues: readOptionalNumber(obj.maxValues),

213+

minValues: readOptionalInteger(obj.minValues, `${label}.minValues`, { min: 0, max: 25 }),

214+

maxValues: readOptionalInteger(obj.maxValues, `${label}.maxValues`, { min: 1, max: 25 }),

202215

options: parseSelectOptions(obj.options, `${label}.options`),

203216

allowedUsers: readOptionalStringArray(obj.allowedUsers, `${label}.allowedUsers`),

204217

};

@@ -224,18 +237,29 @@ function parseModalField(raw: unknown, label: string, index: number): DiscordMod

224237

if (["checkbox", "radio", "select"].includes(type) && (!options || options.length === 0)) {

225238

throw new Error(`${label}.options is required for ${type} fields`);

226239

}

240+

if (type === "radio" && (obj.minValues != null || obj.maxValues != null)) {

241+

throw new Error(`${label}.minValues/maxValues are not supported for radio fields`);

242+

}

243+

const required = typeof obj.required === "boolean" ? obj.required : undefined;

244+

const maxValues = type === "checkbox" ? 10 : 25;

227245

return {

228246

type,

229247

name: normalizeModalFieldName(readOptionalString(obj.name), index),

230248

label: readString(obj.label, `${label}.label`),

231249

description: readOptionalString(obj.description),

232250

placeholder: readOptionalString(obj.placeholder),

233-

required: typeof obj.required === "boolean" ? obj.required : undefined,

251+

required,

234252

options,

235-

minValues: readOptionalNumber(obj.minValues),

236-

maxValues: readOptionalNumber(obj.maxValues),

237-

minLength: readOptionalNumber(obj.minLength),

238-

maxLength: readOptionalNumber(obj.maxLength),

253+

minValues: readOptionalInteger(obj.minValues, `${label}.minValues`, {

254+

min: required === false ? 0 : 1,

255+

max: maxValues,

256+

}),

257+

maxValues: readOptionalInteger(obj.maxValues, `${label}.maxValues`, {

258+

min: 1,

259+

max: maxValues,

260+

}),

261+

minLength: readOptionalInteger(obj.minLength, `${label}.minLength`, { min: 0, max: 4000 }),

262+

maxLength: readOptionalInteger(obj.maxLength, `${label}.maxLength`, { min: 1, max: 4000 }),

239263

style: readOptionalString(obj.style) as DiscordModalFieldSpec["style"],

240264

};

241265

}