mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:20:43 +00:00
Fail fast for removed Codex import auth choice
This commit is contained in:
@@ -42,6 +42,25 @@ async function normalizeTokenProviderChoice(params: {
|
||||
});
|
||||
}
|
||||
|
||||
async function formatDeprecatedProviderChoiceError(
|
||||
authChoice: AuthChoice | undefined,
|
||||
params: Pick<ApplyAuthChoiceParams, "config" | "env">,
|
||||
): Promise<string | undefined> {
|
||||
if (typeof authChoice !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const { resolveManifestDeprecatedProviderAuthChoice } =
|
||||
await import("../plugins/provider-auth-choices.js");
|
||||
const deprecatedChoice = resolveManifestDeprecatedProviderAuthChoice(authChoice, {
|
||||
config: params.config,
|
||||
env: params.env,
|
||||
});
|
||||
if (!deprecatedChoice) {
|
||||
return undefined;
|
||||
}
|
||||
return `Auth choice "${authChoice}" is no longer supported. Use "${deprecatedChoice.choiceId}" instead.`;
|
||||
}
|
||||
|
||||
export async function applyAuthChoice(
|
||||
params: ApplyAuthChoiceParams,
|
||||
): Promise<ApplyAuthChoiceResult> {
|
||||
@@ -63,6 +82,17 @@ export async function applyAuthChoice(
|
||||
return result;
|
||||
}
|
||||
|
||||
const deprecatedProviderChoiceError = await formatDeprecatedProviderChoiceError(
|
||||
normalizedParams.authChoice,
|
||||
{
|
||||
config: normalizedParams.config,
|
||||
env: normalizedParams.env,
|
||||
},
|
||||
);
|
||||
if (deprecatedProviderChoiceError) {
|
||||
throw new Error(deprecatedProviderChoiceError);
|
||||
}
|
||||
|
||||
if (normalizedParams.authChoice === "token" || normalizedParams.authChoice === "setup-token") {
|
||||
throw new Error(
|
||||
[
|
||||
|
||||
@@ -691,6 +691,20 @@ describe("applyAuthChoice", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("fails fast when a removed provider auth choice is passed to the interactive flow", async () => {
|
||||
await expect(
|
||||
applyAuthChoice({
|
||||
authChoice: "openai-codex-import",
|
||||
config: {},
|
||||
prompter: createPrompter({}),
|
||||
runtime: createExitThrowingRuntime(),
|
||||
setDefaultModel: true,
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
'Auth choice "openai-codex-import" is no longer supported. Use "openai-codex" instead.',
|
||||
);
|
||||
});
|
||||
|
||||
it("prompts and writes provider API key profiles for common providers", async () => {
|
||||
const scenarios: Array<{
|
||||
authChoice: "huggingface-api-key";
|
||||
|
||||
Reference in New Issue
Block a user