amir20/dozzle · error

invalid connection string

Error message

invalid connection string: %s

What it means

ParseConnection parses a multi-host connection string of the form 'url|name[|cert]', splitting on '|'. If the string has more than 3 parts or an empty URL part, it returns 'invalid connection string' with the original input. This guards the remote-host configuration format.

Solutions

  1. Format the connection string as 'tcp://host:port|name' (optional third '|cert' segment) with at most two pipes
  2. Remove stray or trailing '|' characters and empty segments from the env/config value
  3. Trim whitespace/empty entries out of the remote hosts list before passing to Dozzle

Example fix

// before
DOZZLE_REMOTE_HOST="tcp://1.2.3.4:2375|remote|"
// after
DOZZLE_REMOTE_HOST="tcp://1.2.3.4:2375|remote"
Defensive patterns

Strategy: validation

Validate before calling

func validConnection(s string) bool {
  parts := strings.Split(s, "|")
  return len(parts) <= 3 && parts[0] != ""
}
// check before setting DOZZLE_REMOTE_HOST

Prevention

When it happens

Trigger: CreateMultiHostService parses a DOZZLE_REMOTE_HOST / remote hosts entry that contains more than two '|' separators or an empty first segment (empty string, leading '|', or '||').

Common situations: Environment variable with a trailing pipe; TCP endpoint mistakenly wrapped with extra metadata after pipes; empty entries in a comma/space-separated remote host list; yml config value left as '||'.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/87d81d9c2139949e. Report an issue: GitHub.

Appendix: source

Thrown at internal/container/host.go:45

	Type          string   `json:"type"`
	Available     bool     `json:"available"`
	Swarm         bool     `json:"-"`
	// SwarmClusterID identifies the swarm this node belongs to, empty outside
	// a swarm. Every node of one swarm reports the same value, which is what
	// lets Dozzle Cloud tell "one swarm, N replicas" apart from one API key
	// reused across unrelated deployments.
	SwarmClusterID string `json:"-"`
	Group          string `json:"group,omitempty"`
}

func (h Host) String() string {
	return fmt.Sprintf("ID: %s, Endpoint: %s, nCPU: %d, memTotal: %d", h.ID, h.Endpoint, h.NCPU, h.MemTotal)
}

func ParseConnection(connection string) (Host, error) {
	parts := strings.Split(connection, "|")
	if len(parts) > 3 || parts[0] == "" {
		return Host{}, fmt.Errorf("invalid connection string: %s", connection)
	}

	remoteUrl, err := url.Parse(parts[0])
	if err != nil {
		return Host{}, err
	}

	name := remoteUrl.Hostname()
	if len(parts) >= 2 && parts[1] != "" {
		name = parts[1]
	}

	group := ""
	if len(parts) == 3 {
		group = parts[2]
	}

	basePath, err := filepath.Abs("./certs")

View on GitHub (pinned to d9463cbe21)