Repository navigation
fix(cli): report an unavailable provider preset as a usage error #8310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,14 +125,32 @@ describe("explicit live provider lifecycle", () => { | |
| expect(force.calls.filter(call => call.method === "POST")).toHaveLength(1); | ||
| }); | ||
|
|
||
| for (const presets of [null, {}, { providers: {} }, { providers: [null] }, { providers: [preset, preset] }, { providers: [{ ...preset, auth: 1 }] }, { providers: [{ ...preset, responsesPath: 3 }] }, { providers: [] }]) { | ||
| for (const presets of [null, {}, { providers: {} }, { providers: [null] }, { providers: [preset, preset] }, { providers: [{ ...preset, auth: 1 }] }, { providers: [{ ...preset, responsesPath: 3 }] }]) { | ||
| test("missing/malformed target preset never falls back or posts", async () => { | ||
| const f = fixture({ presets: presets ?? { providers: null } }); | ||
| expect(await lifecycle("add", ["fixture", "--json"], f.deps)).toBe(1); | ||
| expect(f.calls.map(call => call.method)).toEqual(["GET", "GET"]); | ||
| expect(output).not.toHaveBeenCalled(); | ||
| }); | ||
| } | ||
| for (const args of [["kimi-responses"], ["kimi-responses", "--adapter", "openai-responses"], ["kimi-responses", "--base-url", "https://custom.example.test"]]) { | ||
| test(`preset the target does not offer is a usage error naming it (#8087): ${args.slice(1).join(" ") || "no custom fields"}`, async () => { | ||
| const f = fixture({ presets: { providers: [preset] } }); | ||
| expect(await lifecycle("add", [...args, "--json"], f.deps)).toBe(2); | ||
| expect(f.calls.map(call => call.method)).toEqual(["GET", "GET"]); | ||
| expect(output).not.toHaveBeenCalled(); | ||
| expect(errors.mock.calls[0]?.[0]).toBe('Error: The selected target does not offer a "kimi-responses" preset. Custom providers require --adapter and --base-url.'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| expect(errors.mock.calls.map(call => call[0])).toEqual(expect.arrayContaining(["Usage:", expect.stringContaining("ocx provider add <name> --live")])); | ||
| }); | ||
| } | ||
| test("canonical OpenAI missing from the target is a usage error (#8087)", async () => { | ||
| const f = fixture({ presets: { providers: [] } }); | ||
| expect(await lifecycle("add", ["openai", "--json"], f.deps)).toBe(2); | ||
| expect(f.calls.map(call => call.method)).toEqual(["GET", "GET"]); | ||
| expect(output).not.toHaveBeenCalled(); | ||
| expect(errors.mock.calls[0]?.[0]).toBe("Error: The selected target does not offer the canonical openai preset."); | ||
| expect(errors.mock.calls.map(call => call[0])).toEqual(expect.arrayContaining(["Usage:", expect.stringContaining("ocx provider add <name> --live")])); | ||
| }); | ||
| for (const seed of [undefined, {}, { ...canonicalSeed, apiKey: SENTINEL }, { ...canonicalSeed, baseUrl: "https://wrong.test" }, { ...canonicalSeed, codexAccountMode: "wrong" }]) { | ||
| test("missing/malformed canonical seed cannot fall back to custom flags", async () => { | ||
| const f = fixture({ presets: { providers: [{ id: "openai", provider: seed }] } }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: lidge-jun/opencodex
Length of output: 16721
Script executed:
Repository: lidge-jun/opencodex
Length of output: 31945
Script executed:
Repository: lidge-jun/opencodex
Length of output: 24171
Script executed:
Repository: lidge-jun/opencodex
Length of output: 5826
Document the missing-preset exit code.
In
docs-site/src/content/docs/reference/cli/providers-accounts.md, document that a missing live preset exits 2, including the separate canonicalopenaicase. Scripts cannot find this specific outcome in the current guidance.As per coding guidelines: “Update
docs-site/when the change affects user-visible behavior or configuration.”Source: Coding guidelines