abiosoft/colima · error

error parsing model list: %w

Error message

error parsing model list: %w

What it means

The stdout of `docker model list --json` could not be unmarshalled into []dockerModel. Empty output and `[]` are handled just before, so this fires when the payload is JSON mixed with non-JSON noise (CLI warnings, banner lines) or when the shape changed (object instead of array) — typically version skew between the VM's docker model plugin and this parser.

Source

Thrown at model/runner.go:195

	return "", nil
}

// listDockerModels returns all available models from docker model list.
func listDockerModels() ([]dockerModel, error) {
	guest := lima.New(host.New())
	output, err := guest.RunOutput("docker", "model", "list", "--json")
	if err != nil {
		return nil, fmt.Errorf("error listing models: %w", err)
	}

	output = strings.TrimSpace(output)
	if output == "" || output == "[]" {
		return nil, nil
	}

	var models []dockerModel
	if err := json.Unmarshal([]byte(output), &models); err != nil {
		return nil, fmt.Errorf("error parsing model list: %w", err)
	}

	return models, nil
}

// ResolveModelName resolves a short model name to its full tag.
// Supports flexible matching:
//   - "smollm2" resolves to "docker.io/ai/smollm2:latest"
//   - "ai/smollm2" resolves to "docker.io/ai/smollm2:latest"
//   - "hf.co/..." resolves to "huggingface.co/..."
//
// Returns the original name if no match is found (for new models to be pulled).
func ResolveModelName(name string) (string, error) {
	models, err := listDockerModels()
	if err != nil {
		return name, err
	}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Dump the raw payload to see what is extra: colima ssh -- docker model list --json
  2. Align versions: upgrade colima and/or the VM docker engine so the output matches the expected schema
  3. If you control the caller, strip non-JSON noise before Unmarshal (see example fix)

Example fix

// before
var models []dockerModel
if err := json.Unmarshal([]byte(output), &models); err != nil {
	return nil, fmt.Errorf("error parsing model list: %w", err)
}

// after: drop CLI noise around the JSON array
if s := strings.Index(output, "["); s > 0 {
	if e := strings.LastIndex(output, "]"); e > s {
		output = output[s : e+1]
	}
}
var models []dockerModel
if err := json.Unmarshal([]byte(output), &models); err != nil {
	return nil, fmt.Errorf("error parsing model list: %w", err)
}
Defensive patterns

Strategy: try-catch

Try / catch

var typeErr *json.UnmarshalTypeError
if errors.As(err, &typeErr) {
	// payload shape changed (object vs array): version skew — dump raw output and align versions
} else {
	// SyntaxError: noise in stdout — sanitize around the JSON array and retry once
}

Prevention

When it happens

Trigger: A newer or older docker model plugin printing warnings or a wrapper object to stdout; VM shell interleaving log lines with the JSON payload; any plugin output-format change.

Common situations: Version mismatch after upgrading the VM's docker engine but not colima, or vice versa.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/4651aab5527c517e. Report an issue: GitHub.