abiosoft/colima · error

error decoding remotes response: %w

Error message

error decoding remotes response: %w

What it means

The JSON emitted by host 'incus remote list --format json' could not be decoded into the remoteInfo map. Either the command printed non-JSON ahead of the payload (warnings, update notices), or the incus version changed the JSON shape so the Go struct no longer matches.

Source

Thrown at environment/container/incus/incus.go:368

func (c incusRuntime) hasRemote(name string) bool {
	remotes, err := c.fetchRemotes()
	if err != nil {
		return false
	}

	_, ok := remotes[name]
	return ok
}

func (c incusRuntime) fetchRemotes() (remoteInfo, error) {
	b, err := c.host.RunOutput("incus", "remote", "list", "--format", "json")
	if err != nil {
		return nil, fmt.Errorf("error fetching remotes: %w", err)
	}

	var remotes remoteInfo
	if err := json.NewDecoder(strings.NewReader(b)).Decode(&remotes); err != nil {
		return nil, fmt.Errorf("error decoding remotes response: %w", err)
	}

	return remotes, nil
}

func (c incusRuntime) isDefaultRemote() bool {
	remote, _ := c.host.RunOutput("incus", "remote", "get-default")
	return remote == config.CurrentProfile().ID
}

func (c incusRuntime) addDockerRemote() error {
	if c.hasRemote("docker") {
		// already added
		return nil
	}

	return c.host.RunQuiet("incus", "remote", "add", "docker", "https://docker.io", "--protocol=oci")
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Run 'incus remote list --format json' on the host and paste the output into a JSON validator to spot non-JSON prefix
  2. Align versions: upgrade colima to a release supporting your host incus, or pin incus to a compatible version
  3. Clear host incus update notices / re-run the command to dismiss one-time warnings
  4. Report the output shape to colima maintainers if a new incus schema is the cause
Defensive patterns

Strategy: validation

Validate before calling

// strip non-JSON noise before decoding: keep from first '{'
if i := strings.Index(b, "{"); i > 0 {
    b = b[i:]
}
var remotes remoteInfo
if err := json.NewDecoder(strings.NewReader(b)).Decode(&remotes); err != nil {
    return nil, fmt.Errorf("error decoding remotes response: %w", err)
}

Try / catch

var remotes remoteInfo
if err := json.Unmarshal([]byte(strings.TrimSpace(b)), &remotes); err != nil {
    if strings.HasPrefix(strings.TrimSpace(b), "{") {
        return nil, fmt.Errorf("incus remote schema changed, upgrade colima: %w", err)
    }
    return nil, fmt.Errorf("non-JSON output from incus: %w", err)
}

Prevention

When it happens

Trigger: json.Decode into remoteInfo fails: stdout contains log/warning lines before JSON, incus prints a deprecation notice, or the schema of remote entries changed (renamed/added required fields) across versions.

Common situations: Host incus auto-update notice printed to stdout, older/newer incus than colima supports, locale-specific output, or a partially written client config producing warning output.

Related errors


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