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

推荐订阅源

J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
D
Docker
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
量子位
有赞技术团队
有赞技术团队
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
B
Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
月光博客
月光博客

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: reject partial numeric parsing · openclaw/openclaw@f...
steipete · 2026-05-28 · via Recent Commits to openclaw:main

File tree

    • mattermost/src/mattermost

Original file line numberDiff line numberDiff line change

@@ -148,9 +148,9 @@ function parseRawPage(value: unknown): number {

148148

if (typeof value === "number") {

149149

return normalizeModelPickerPage(value);

150150

}

151-

if (typeof value === "string" && value.trim()) {

152-

const parsed = Number.parseInt(value, 10);

153-

if (Number.isFinite(parsed)) {

151+

if (typeof value === "string" && /^[+-]?\d+$/.test(value.trim())) {

152+

const parsed = Number(value.trim());

153+

if (Number.isSafeInteger(parsed)) {

154154

return normalizeModelPickerPage(parsed);

155155

}

156156

}

@@ -161,11 +161,15 @@ function parseRawPositiveInt(value: unknown): number | undefined {

161161

if (typeof value !== "string" && typeof value !== "number") {

162162

return undefined;

163163

}

164-

const parsed = Number.parseInt(String(value), 10);

165-

if (!Number.isFinite(parsed) || parsed < 1) {

164+

const raw = String(value).trim();

165+

if (!/^[+]?\d+$/.test(raw)) {

166166

return undefined;

167167

}

168-

return Math.floor(parsed);

168+

const parsed = Number(raw);

169+

if (!Number.isSafeInteger(parsed) || parsed < 1) {

170+

return undefined;

171+

}

172+

return parsed;

169173

}

170174
171175

function coerceString(value: unknown): string {

Original file line numberDiff line numberDiff line change

@@ -184,6 +184,27 @@ describe("Discord model picker custom_id", () => {

184184

});

185185

});

186186
187+

it("does not coerce partial numeric custom_id fields", () => {

188+

expect(

189+

parseDiscordModelPickerData({

190+

cmd: "models",

191+

act: "submit",

192+

view: "models",

193+

u: "42",

194+

p: "openai",

195+

pg: "3next",

196+

mi: "7model",

197+

}),

198+

).toEqual({

199+

command: "models",

200+

action: "submit",

201+

view: "models",

202+

userId: "42",

203+

provider: "openai",

204+

page: 1,

205+

});

206+

});

207+
187208

it("rejects invalid command/action/view values", () => {

188209

expect(

189210

parseDiscordModelPickerData({

Original file line numberDiff line numberDiff line change

@@ -136,6 +136,23 @@ describe("Mattermost model picker", () => {

136136

expect(parseMattermostModelPickerContext({ action: "select" })).toBeNull();

137137

});

138138
139+

it("does not coerce partial page strings in signed picker contexts", () => {

140+

expect(

141+

parseMattermostModelPickerContext({

142+

oc_model_picker: true,

143+

action: "list",

144+

ownerUserId: "user-1",

145+

provider: "openai",

146+

page: "2next",

147+

}),

148+

).toEqual({

149+

action: "list",

150+

ownerUserId: "user-1",

151+

provider: "openai",

152+

page: 1,

153+

});

154+

});

155+
139156

it("falls back to the routed agent default model when no override is stored", () => {

140157

const testDir = fs.mkdtempSync(path.join(os.tmpdir(), "mm-model-picker-"));

141158

try {

Original file line numberDiff line numberDiff line change

@@ -62,9 +62,9 @@ function readContextNumber(context: Record<string, unknown>, key: string): numbe

6262

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

6363

return value;

6464

}

65-

if (typeof value === "string") {

66-

const parsed = Number.parseInt(value.trim(), 10);

67-

if (Number.isFinite(parsed)) {

65+

if (typeof value === "string" && /^[+-]?\d+$/.test(value.trim())) {

66+

const parsed = Number(value.trim());

67+

if (Number.isSafeInteger(parsed)) {

6868

return parsed;

6969

}

7070

}

Original file line numberDiff line numberDiff line change

@@ -935,7 +935,8 @@ export default definePluginEntry({

935935

.option("--limit <n>", "Max results", "5")

936936

.action(async (query, opts) => {

937937

const vector = await embeddings.embed(normalizeRecallQuery(query, cfg.recallMaxChars));

938-

const results = await db.search(vector, Number.parseInt(opts.limit, 10), 0.3);

938+

const limit = parsePositiveIntegerOption(opts.limit, "--limit");

939+

const results = await db.search(vector, limit, 0.3);

939940

// Strip vectors for output

940941

const output = results.map((r) => ({

941942

id: r.entry.id,

@@ -983,10 +984,7 @@ export default definePluginEntry({

983984

}

984985

query = query.where(filterCondition);

985986

}

986-

const limit = Number.parseInt(opts.limit, 10);

987-

if (Number.isNaN(limit) || limit <= 0) {

988-

throw new Error("Invalid limit: must be a positive integer");

989-

}

987+

const limit = parsePositiveIntegerOption(opts.limit, "--limit") ?? 10;

990988
991989

// Fetch all filtered rows first if we need to order them in memory

992990

if (!opts.orderBy) {

Original file line numberDiff line numberDiff line change

@@ -36,7 +36,7 @@ function account(

3636

};

3737

}

3838
39-

function mockBotAdmin(features: number): void {

39+

function mockBotAdmin(features: number | string): void {

4040

hoisted.fetchWithSsrFGuard.mockResolvedValueOnce({

4141

response: new Response(

4242

JSON.stringify({

@@ -94,6 +94,19 @@ describe("probeNextcloudTalkBotResponseFeature", () => {

9494

});

9595

});

9696
97+

it("does not coerce partial bot feature strings", async () => {

98+

mockBotAdmin("2response");

99+
100+

await expect(probeNextcloudTalkBotResponseFeature({ account: account() })).resolves.toEqual({

101+

ok: false,

102+

code: "missing_response_feature",

103+

botId: "7",

104+

botName: "OpenClaw",

105+

message:

106+

'Nextcloud Talk bot "OpenClaw" (7) is missing the response feature; outbound replies will fail. Run ./occ talk:bot:state --feature webhook --feature response --feature reaction 7 1 or reinstall the bot with --feature response.',

107+

});

108+

});

109+
97110

it("reports malformed bot admin JSON with a stable channel error", async () => {

98111

hoisted.fetchWithSsrFGuard.mockResolvedValueOnce({

99112

response: new Response("{ nope", {

Original file line numberDiff line numberDiff line change

@@ -50,9 +50,9 @@ function coerceFeatureMask(value: unknown): number | undefined {

5050

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

5151

return value;

5252

}

53-

if (typeof value === "string" && value.trim()) {

54-

const parsed = Number.parseInt(value, 10);

55-

return Number.isFinite(parsed) ? parsed : undefined;

53+

if (typeof value === "string" && /^[+-]?\d+$/.test(value.trim())) {

54+

const parsed = Number(value.trim());

55+

return Number.isSafeInteger(parsed) ? parsed : undefined;

5656

}

5757

return undefined;

5858

}

Original file line numberDiff line numberDiff line change

@@ -73,6 +73,36 @@ describe("nextcloud talk room info", () => {

7373

expect(release).toHaveBeenCalledTimes(1);

7474

});

7575
76+

it("does not coerce partial room type strings", async () => {

77+

fetchWithSsrFGuard.mockResolvedValue({

78+

response: {

79+

ok: true,

80+

json: async () => ({

81+

ocs: {

82+

data: {

83+

type: "1direct",

84+

},

85+

},

86+

}),

87+

},

88+

release: vi.fn(async () => {}),

89+

});

90+
91+

await expect(

92+

resolveNextcloudTalkRoomKind({

93+

account: {

94+

accountId: "acct-partial",

95+

baseUrl: "https://nc.example.com",

96+

config: {

97+

apiUser: "bot",

98+

apiPassword: "secret",

99+

},

100+

} as never,

101+

roomToken: "room-partial",

102+

}),

103+

).resolves.toBeUndefined();

104+

});

105+
76106

it("reads the api password from a file and logs non-ok room info responses", async () => {

77107

const release = vi.fn(async () => {});

78108

const log = vi.fn();

Original file line numberDiff line numberDiff line change

@@ -27,9 +27,9 @@ function coerceRoomType(value: unknown): number | undefined {

2727

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

2828

return value;

2929

}

30-

if (typeof value === "string" && value.trim()) {

31-

const parsed = Number.parseInt(value, 10);

32-

return Number.isFinite(parsed) ? parsed : undefined;

30+

if (typeof value === "string" && /^[+-]?\d+$/.test(value.trim())) {

31+

const parsed = Number(value.trim());

32+

return Number.isSafeInteger(parsed) ? parsed : undefined;

3333

}

3434

return undefined;

3535

}

Original file line numberDiff line numberDiff line change

@@ -44,6 +44,19 @@ describe("TwilioStreamFrameAdapter", () => {

4444

).toEqual({ kind: "ignored" });

4545

});

4646
47+

it("ignores partial numeric media timestamps", () => {

48+

const adapter = new TwilioStreamFrameAdapter();

49+
50+

expect(

51+

adapter.parseInbound(

52+

JSON.stringify({

53+

event: "media",

54+

media: { payload: "AAA=", timestamp: "20ms" },

55+

}),

56+

),

57+

).toEqual({ kind: "media", payloadBase64: "AAA=" });

58+

});

59+
4760

it("serializes outbound frames with the streamSid captured at start", () => {

4861

const adapter = new TwilioStreamFrameAdapter();

4962

adapter.parseInbound(