Skip to content

[Bug] init fails when model discovery succeeds with an empty model list #316

Description

@404-Page-Found

Description

The setup wizard treats model discovery as successful whenever fetchModels() resolves. It does not handle a successful response that contains zero models.

For OpenAI-compatible and Cohere providers, an empty model array can be returned without an HTTP/protocol error, but promptModel() immediately feeds the empty array into the interactive select() prompt. There is no manual-model fallback unless fetchModels() throws.

Location

  • src/commands/init.ts:161-184promptModel()
  • src/providers/openai-compatible.ts:99-123fetchModels()
  • src/providers/cohere.tsfetchModels()

Relevant code

models = await fetchModels(...);
// no empty-list check
...
const selectedModel = await select({
  message: 'Select a model:',
  options: models.map((model) => ({ value: model, label: model })),
  initialValue: existingConfig?.model,
});

The catch branch that provides Enter model name manually: runs only when fetchModels() rejects.

Steps to Reproduce

  1. Configure an OpenAI-compatible or Cohere endpoint whose model-list request returns HTTP 200 with an empty array.
  2. Run commit-echo init.
  3. Model discovery reports success.
  4. The setup wizard then attempts to display a model selection prompt with no options instead of asking for a model name.

Expected Behavior

An empty model list should fall back to the existing manual model-entry flow.

Actual Behavior

The wizard reaches an empty select() options array and cannot proceed normally through model selection.

Suggested Fix

Treat models.length === 0 as a discovery failure (or a distinct empty-result state) and invoke the manual model prompt. Add tests for HTTP 200 empty model lists for every provider that performs model discovery.

Impact

Provider endpoints that do not expose a populated model catalogue can make the primary init setup wizard unusable even though the endpoint itself is reachable and otherwise compatible.

Reviewed against current main at 6c01ad0a853501e9617a3af0a5db3b515dd8ed53.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingp1High priority; blocks core functionality

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions