nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] A provider with no "models" list is not rejected: the request is sent with an empty model name

Open addyCooks opened this issue 1 month ago • 2 comments

Description

schemas/agents.config.schema.json says a provider needs name and models. The code does not check: source/client-factory.ts:209 turns a missing list into [], and an empty list means "accept any --model". With no --model either, no model is chosen, the banner shows an empty model name, and the server answers with a raw error.

Environment

  • OS: Windows 11 (10.0.26300)
  • Node version: 22.22.3
  • Nanocoder version: 1.31.0 (main at 9d88dda7)
  • Provider: Ollama (OpenAI-compatible endpoint)
  • Model: none configured

Steps to Reproduce

  1. Use this config: {"nanocoder":{"providers":[{"name":"Ollama","baseUrl":"http://localhost:11434/v1"}]}}.
  2. Run nanocoder --trust-directory run "Reply with the single word OK" (no --model).
  3. Run the same with --json.

Expected Behavior

Before any request: Provider "Ollama" has no models configured. Add a "models" list in <config path> or pass --model.

Actual Behavior

nanocoder · Ollama ·  · auto-accept
Bad request: model is required
URL: http://localhost:11434/v1/chat/completions
Response body: {"error":{"message":"model is required","type":"invalid_request_error","param":null,"code":null}}
(exit 1)

Suggested Fix

  • After the provider and model are resolved in source/client-factory.ts (around lines 125-135 and 209), throw a ConfigurationError when the resolved model is empty. Name the provider and the config path.
  • Test: a provider with no models and no --model gives that error.

Additional Context

  • Related: #1652 (config problems are hidden in run mode), which also affects how this is shown.
  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

addyCooks avatar Oct 13 '26 12:10 addyCooks

I can take this. I’ll add the missing-model check before client creation, keep explicit --model support, and add a focused regression test.

CreedTech avatar Oct 13 '26 20:10 CreedTech

Hey @CreedTech , assigning this one to you! Just a heads-up for next time: please wait for the assignment before opening a PR. Thanks!

addyCooks avatar Oct 17 '26 06:10 addyCooks