fix(agents): centralize failover status parsing · openclaw/openclaw@2cd0c8b
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -77,6 +77,8 @@ describe("failover-error", () => {
|
77 | 77 | }), |
78 | 78 | ).toBe("billing"); |
79 | 79 | expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit"); |
| 80 | +expect(resolveFailoverReasonFromError({ statusCode: "+429" })).toBe("rate_limit"); |
| 81 | +expect(resolveFailoverReasonFromError({ statusCode: "0x1ad" })).toBeNull(); |
80 | 82 | expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth"); |
81 | 83 | expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout"); |
82 | 84 | expect(resolveFailoverReasonFromError({ status: 410 })).toBe("timeout"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { readErrorName } from "../infra/errors.js"; |
| 2 | +import { parseStrictNonNegativeInteger } from "../shared/number-coercion.js"; |
2 | 3 | import { |
3 | 4 | classifyFailoverSignal, |
4 | 5 | inferSignalStatus, |
@@ -132,8 +133,8 @@ function readDirectStatusCode(err: unknown): number | undefined {
|
132 | 133 | if (typeof candidate === "number") { |
133 | 134 | return candidate; |
134 | 135 | } |
135 | | -if (typeof candidate === "string" && /^\d+$/.test(candidate)) { |
136 | | -return Number(candidate); |
| 136 | +if (typeof candidate === "string") { |
| 137 | +return parseStrictNonNegativeInteger(candidate); |
137 | 138 | } |
138 | 139 | return undefined; |
139 | 140 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。