fix: reject exponent provider integer options · openclaw/openclaw@03e6181
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1504,6 +1504,25 @@ describe("config cli", () => {
|
1504 | 1504 | }); |
1505 | 1505 | }); |
1506 | 1506 | |
| 1507 | +it("rejects exponent-style provider builder integer options", async () => { |
| 1508 | +await expect( |
| 1509 | +runConfigCommand([ |
| 1510 | +"config", |
| 1511 | +"set", |
| 1512 | +"secrets.providers.runner", |
| 1513 | +"--provider-source", |
| 1514 | +"exec", |
| 1515 | +"--provider-command", |
| 1516 | +"op", |
| 1517 | +"--provider-timeout-ms", |
| 1518 | +"1e3", |
| 1519 | +]), |
| 1520 | +).rejects.toThrow("--provider-timeout-ms must be a positive integer."); |
| 1521 | + |
| 1522 | +expect(mockReadConfigFileSnapshot).not.toHaveBeenCalled(); |
| 1523 | +expect(mockWriteConfigFile).not.toHaveBeenCalled(); |
| 1524 | +}); |
| 1525 | + |
1507 | 1526 | it("runs resolvability checks in builder dry-run mode without writing", async () => { |
1508 | 1527 | const resolved: OpenClawConfig = { |
1509 | 1528 | gateway: { port: 18789 }, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,7 @@ import {
|
33 | 33 | } from "../config/validation.js"; |
34 | 34 | import { SecretProviderSchema } from "../config/zod-schema.core.js"; |
35 | 35 | import { danger, info, success } from "../globals.js"; |
| 36 | +import { parseStrictPositiveInteger } from "../infra/parse-finite-number.js"; |
36 | 37 | import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js"; |
37 | 38 | import { defaultRuntime } from "../runtime.js"; |
38 | 39 | import { |
@@ -1014,8 +1015,8 @@ function parseOptionalPositiveInteger(raw: string | undefined, flag: string): nu
|
1014 | 1015 | if (!trimmed) { |
1015 | 1016 | throw new Error(`${flag} must not be empty.`); |
1016 | 1017 | } |
1017 | | -const parsed = Number(trimmed); |
1018 | | -if (!Number.isInteger(parsed) || parsed <= 0) { |
| 1018 | +const parsed = parseStrictPositiveInteger(trimmed); |
| 1019 | +if (parsed === undefined) { |
1019 | 1020 | throw new Error(`${flag} must be a positive integer.`); |
1020 | 1021 | } |
1021 | 1022 | return parsed; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。