OpenNHP/opennhp · error

: [[Servers]][ ] ( ) has no instances

Error message

%s: [[Servers]][%d] (%s) has no instances

What it means

Cluster-config validation error from Normalize: a [[Servers]] entry has no [[Servers.Instances]] and no legacy top-level address fields either, so the cluster would contain zero reachable endpoints. Entries with legacy fields are auto-upgraded; this error fires only for the genuinely empty case.

Solutions

  1. Add at least one [[Servers.Instances]] block with Host/Ip and Port
  2. Or restore the legacy top-level Hostname/Ip/Port fields to let the auto-upgrade path fill Instances
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nhp/common/clusterconfig/clusterconfig.go:188 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07). Data as JSON: /api/errors/9bafddd3d0cbc1cf. Report an issue: GitHub.

Appendix: source

Thrown at nhp/common/clusterconfig/clusterconfig.go:188

			// incomplete migration. Refuse to guess which one the
			// operator meant.
			return fmt.Errorf("%s: [[Servers]][%d] (%s) sets both top-level Ip/Hostname/Port and [[Servers.Instances]]; "+
				"pick one form — top-level fields are deprecated, prefer Instances",
				label, i, c.PubKeyBase64)
		case legacy && !hasInstances:
			deprecate("%s: [[Servers]][%d] uses legacy single-server form (Hostname/Ip/Port at top level); "+
				"migrate to [[Servers.Instances]] in server.toml — auto-upgrading for now",
				label, i)
			c.Instances = []InstanceConfig{{
				Host:   c.Hostname,
				Ip:     c.Ip,
				Port:   c.Port,
				Weight: 1,
			}}
			// Zero the legacy fields so downstream code never sees both.
			c.Hostname, c.Ip, c.Port = "", "", 0
		case !legacy && !hasInstances:
			return fmt.Errorf("%s: [[Servers]][%d] (%s) has no instances", label, i, c.PubKeyBase64)
		}

		if err := c.LoadBalance.Validate(); err != nil {
			return fmt.Errorf("%s: [[Servers]][%d] (%s): %w", label, i, c.PubKeyBase64, err)
		}
		c.LoadBalance = c.LoadBalance.Normalize()

		for j := range c.Instances {
			inst := &c.Instances[j]
			if inst.Host == "" && inst.Ip == "" {
				return fmt.Errorf("%s: [[Servers]][%d] instance #%d: Host and Ip both empty", label, i, j)
			}
			if inst.Port <= 0 {
				return fmt.Errorf("%s: [[Servers]][%d] instance #%d: invalid Port %d", label, i, j, inst.Port)
			}
			if inst.Weight <= 0 {
				inst.Weight = 1
			}

View on GitHub (pinned to 6e04ca5ff0)