Fail fast for removed Codex import auth choice · openclaw/openclaw@c71f07b
pashpashpash
·
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,25 @@ async function normalizeTokenProviderChoice(params: {
|
42 | 42 | }); |
43 | 43 | } |
44 | 44 | |
| 45 | +async function formatDeprecatedProviderChoiceError( |
| 46 | +authChoice: AuthChoice | undefined, |
| 47 | +params: Pick<ApplyAuthChoiceParams, "config" | "env">, |
| 48 | +): Promise<string | undefined> { |
| 49 | +if (typeof authChoice !== "string") { |
| 50 | +return undefined; |
| 51 | +} |
| 52 | +const { resolveManifestDeprecatedProviderAuthChoice } = |
| 53 | +await import("../plugins/provider-auth-choices.js"); |
| 54 | +const deprecatedChoice = resolveManifestDeprecatedProviderAuthChoice(authChoice, { |
| 55 | +config: params.config, |
| 56 | +env: params.env, |
| 57 | +}); |
| 58 | +if (!deprecatedChoice) { |
| 59 | +return undefined; |
| 60 | +} |
| 61 | +return `Auth choice "${authChoice}" is no longer supported. Use "${deprecatedChoice.choiceId}" instead.`; |
| 62 | +} |
| 63 | + |
45 | 64 | export async function applyAuthChoice( |
46 | 65 | params: ApplyAuthChoiceParams, |
47 | 66 | ): Promise<ApplyAuthChoiceResult> { |
@@ -63,6 +82,17 @@ export async function applyAuthChoice(
|
63 | 82 | return result; |
64 | 83 | } |
65 | 84 | |
| 85 | +const deprecatedProviderChoiceError = await formatDeprecatedProviderChoiceError( |
| 86 | +normalizedParams.authChoice, |
| 87 | +{ |
| 88 | +config: normalizedParams.config, |
| 89 | +env: normalizedParams.env, |
| 90 | +}, |
| 91 | +); |
| 92 | +if (deprecatedProviderChoiceError) { |
| 93 | +throw new Error(deprecatedProviderChoiceError); |
| 94 | +} |
| 95 | + |
66 | 96 | if (normalizedParams.authChoice === "token" || normalizedParams.authChoice === "setup-token") { |
67 | 97 | throw new Error( |
68 | 98 | [ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -691,6 +691,20 @@ describe("applyAuthChoice", () => {
|
691 | 691 | ); |
692 | 692 | }); |
693 | 693 | |
| 694 | +it("fails fast when a removed provider auth choice is passed to the interactive flow", async () => { |
| 695 | +await expect( |
| 696 | +applyAuthChoice({ |
| 697 | +authChoice: "openai-codex-import", |
| 698 | +config: {}, |
| 699 | +prompter: createPrompter({}), |
| 700 | +runtime: createExitThrowingRuntime(), |
| 701 | +setDefaultModel: true, |
| 702 | +}), |
| 703 | +).rejects.toThrow( |
| 704 | +'Auth choice "openai-codex-import" is no longer supported. Use "openai-codex" instead.', |
| 705 | +); |
| 706 | +}); |
| 707 | + |
694 | 708 | it("prompts and writes provider API key profiles for common providers", async () => { |
695 | 709 | const scenarios: Array<{ |
696 | 710 | authChoice: "huggingface-api-key"; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。