fix(auth): clarify Codex OAuth region failures (#71501) · openclaw/openclaw@65ea6a0
vincentkoc
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,7 @@ Docs: https://docs.openclaw.ai
|
19 | 19 | - Google Chat: preserve reply text when a typing indicator message is deleted or can no longer be updated, so media captions and first text chunks are resent instead of silently disappearing. (#71498) Thanks @colin-lgtm. |
20 | 20 | - Heartbeat: clamp oversized scheduler delays through the shared safe timer helper, preventing `every` values over Node's timeout cap from becoming a 1 ms crash loop. Fixes #71414. (#71478) Thanks @hclsys. |
21 | 21 | - Control UI/chat: collapse assistant token/model context details behind an explicit Context disclosure and show full dates in message footers, making historical transcript timing clear without noisy default metadata. (#71337) Thanks @BunsDev. |
| 22 | +- OpenAI/Codex OAuth: explain `unsupported_country_region_territory` token-exchange failures with a proxy/region hint instead of surfacing a generic OAuth error. Fixes #51175. |
22 | 23 | - Telegram: remove the startup persisted-offset `getUpdates` preflight so polling restarts do not self-conflict before the runner starts. Fixes #69304. (#69779) Thanks @chinar-amrutkar. |
23 | 24 | - Telegram: keep the polling stall watchdog active even when grammY reports the runner as not running while its task is still pending, so a rebuilt transport cannot leave `getUpdates` silent until a manual gateway restart. Fixes #69064. Thanks @LDLoeb. |
24 | 25 | - Browser/Playwright: ignore benign already-handled route races during guarded navigation so browser-page tasks no longer fail when Playwright tears down a route mid-flight. (#68708) Thanks @Steady-ai. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -181,6 +181,28 @@ describe("loginOpenAICodexOAuth", () => {
|
181 | 181 | ); |
182 | 182 | }); |
183 | 183 | |
| 184 | +it("explains OpenAI unsupported region token exchange failures", async () => { |
| 185 | +mocks.loginOpenAICodex.mockRejectedValue(new Error("403 unsupported_country_region_territory")); |
| 186 | + |
| 187 | +const { prompter, spin } = createPrompter(); |
| 188 | +const runtime = createRuntime(); |
| 189 | +await expect( |
| 190 | +loginOpenAICodexOAuth({ |
| 191 | + prompter, |
| 192 | + runtime, |
| 193 | +isRemote: false, |
| 194 | +openUrl: async () => {}, |
| 195 | +}), |
| 196 | +).rejects.toThrow(/unsupported_region/i); |
| 197 | + |
| 198 | +expect(spin.stop).toHaveBeenCalledWith("OpenAI OAuth failed"); |
| 199 | +expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("HTTPS_PROXY")); |
| 200 | +expect(prompter.note).toHaveBeenCalledWith( |
| 201 | +"Trouble with OAuth? See https://docs.openclaw.ai/start/faq", |
| 202 | +"OAuth help", |
| 203 | +); |
| 204 | +}); |
| 205 | + |
184 | 206 | it("passes manual code input hook for remote oauth flows", async () => { |
185 | 207 | const creds = createCodexCredentials(); |
186 | 208 | mocks.loginOpenAICodex.mockImplementation(async (opts: CodexLoginOptions) => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,10 @@ const openAICodexOAuthOriginator = "openclaw";
|
15 | 15 | const localManualFallbackDelayMs = 15_000; |
16 | 16 | const localManualFallbackGraceMs = 1_000; |
17 | 17 | |
18 | | -type OpenAICodexOAuthFailureCode = "callback_timeout" | "callback_validation_failed"; |
| 18 | +type OpenAICodexOAuthFailureCode = |
| 19 | +| "callback_timeout" |
| 20 | +| "callback_validation_failed" |
| 21 | +| "unsupported_region"; |
19 | 22 | |
20 | 23 | function waitForDelayOrLoginSettle(params: { |
21 | 24 | delayMs: number; |
@@ -54,6 +57,16 @@ function createOpenAICodexOAuthError(
|
54 | 57 | |
55 | 58 | function rewriteOpenAICodexOAuthError(error: unknown): Error { |
56 | 59 | const message = formatErrorMessage(error); |
| 60 | +if (/unsupported_country_region_territory/i.test(message)) { |
| 61 | +return createOpenAICodexOAuthError( |
| 62 | +"unsupported_region", |
| 63 | +[ |
| 64 | +"OpenAI rejected the token exchange for this country, region, or network route.", |
| 65 | +"If you normally use a proxy, verify HTTPS_PROXY, HTTP_PROXY, or ALL_PROXY is set for the OpenClaw process and then retry `openclaw models auth login --provider openai-codex`.", |
| 66 | +].join(" "), |
| 67 | +error, |
| 68 | +); |
| 69 | +} |
57 | 70 | if (/state mismatch|missing authorization code/i.test(message)) { |
58 | 71 | return createOpenAICodexOAuthError("callback_validation_failed", message, error); |
59 | 72 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。