docker/compose · error

error unmarshalling available models: %w

Error message

error unmarshalling available models: %w

What it means

After `docker model ls --json` succeeds, compose unmarshals its stdout into a []AvailableModel. If the bytes are not that JSON shape, unmarshalling fails and is wrapped here. The plugin exited 0 but emitted something other than the expected array (or stdout is polluted by warnings).

Source

Thrown at pkg/compose/model.go:274

	if err != nil {
		return nil, err
	}

	output, err := cmd.CombinedOutput()
	if err != nil {
		return nil, fmt.Errorf("error checking available models: %w", err)
	}

	type AvailableModel struct {
		Id      string   `json:"id"`
		Tags    []string `json:"tags"`
		Created int      `json:"created"`
	}

	models := []AvailableModel{}
	err = json.Unmarshal(output, &models)
	if err != nil {
		return nil, fmt.Errorf("error unmarshalling available models: %w", err)
	}
	var availableModels []string
	for _, model := range models {
		availableModels = append(availableModels, model.Tags...)
	}
	return availableModels, nil
}

// supportsRuntimeFlags checks if the docker model version supports runtime flags
// Runtime flags are supported in version >= v1.0.6
func (m *modelAPI) supportsRuntimeFlags() bool {
	// If version is not cached, don't append runtime flags to be safe
	if m.version == "" {
		return false
	}

	// Strip 'v' prefix if present (e.g., "v1.0.6" -> "1.0.6")
	versionStr := strings.TrimPrefix(m.version, "v")

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Capture and inspect the raw output: docker model ls --json | head; check it starts with '['
  2. Align versions: upgrade compose and/or the model plugin so their contract matches
  3. Report/fix the plugin if it prints non-JSON noise on stdout
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command("docker", "model", "ls", "--json").Output()
if err != nil { return err }
if !json.Valid(out) || !bytes.HasPrefix(bytes.TrimSpace(out), []byte("[")) {
    return errors.New("model plugin emitted unexpected output; align plugin and compose versions")
}

Prevention

When it happens

Trigger: Plugin output containing a leading warning/log line before the JSON; schema change in a newer/older plugin (object instead of array); empty output; text error printed on stdout with exit 0.

Common situations: Version skew between compose and the model plugin; plugins that log to stdout; locale/env-triggered notices corrupting machine-readable output.

Related errors


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/4eb4de43a2a02914. Report an issue: GitHub.