t8y2/dbx · error

invalid Hive endpoint %q: %w

Error message

invalid Hive endpoint %q: %w

What it means

parseEndpoint accepts host:port (via net.SplitHostPort) or plain host forms. If a colon-containing value looks like host:port but the port substring fails strconv.Atoi, the driver rejects the endpoint with this wrapped error. Note SplitHostPort may succeed for IPv6 literals, so this branch fires when a port was explicitly parsed but is not numeric.

Source

Thrown at agents/drivers/hive-go/config.go:399

		if trimmed := strings.TrimSpace(part); trimmed != "" {
			result = append(result, trimmed)
		}
	}
	return result
}

func parseEndpoint(value string, defaultPort int) (endpoint, error) {
	value = strings.TrimSpace(value)
	if value == "" {
		return endpoint{}, errors.New("Hive endpoint is empty")
	}
	host := value
	port := defaultPort
	if parsedHost, parsedPort, err := net.SplitHostPort(value); err == nil {
		host = parsedHost
		parsed, parseErr := strconv.Atoi(parsedPort)
		if parseErr != nil {
			return endpoint{}, fmt.Errorf("invalid Hive endpoint %q: %w", value, parseErr)
		}
		port = parsed
	} else if strings.Count(value, ":") == 1 {
		parts := strings.SplitN(value, ":", 2)
		parsed, parseErr := strconv.Atoi(parts[1])
		if parseErr != nil {
			return endpoint{}, fmt.Errorf("invalid Hive endpoint %q: %w", value, parseErr)
		}
		host = parts[0]
		port = parsed
	} else if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") {
		host = strings.Trim(value, "[]")
	}
	if strings.TrimSpace(host) == "" || port <= 0 || port > 65535 {
		return endpoint{}, fmt.Errorf("invalid Hive endpoint %q", value)
	}
	return endpoint{Host: host, Port: port}, nil
}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Fix the port to a decimal integer after the colon
  2. Drop the :port suffix to use the default port for a plain host
  3. Check the wrapped strconv error for the exact bad token
  4. Validate endpoint strings in config before constructing the client

Example fix

// before
endpoints := []string{"hs2.internal:PORT"}
// after
endpoints := []string{"hs2.internal:10000"}
Defensive patterns

Strategy: validation

Validate before calling

func validEndpoint(s string) bool {
    if h, p, err := net.SplitHostPort(s); err == nil {
        n, err := strconv.Atoi(p)
        return h != "" && err == nil && n > 0 && n <= 65535
    }
    if i := strings.LastIndex(s, ":"); i >= 0 {
        n, err := strconv.Atoi(s[i+1:])
        return s[:i] != "" && err == nil && n > 0 && n <= 65535
    }
    return strings.TrimSpace(s) != ""
}

Try / catch

ep, err := parseEndpoint(value)
if err != nil {
    if strings.Contains(err.Error(), "invalid Hive endpoint") {
        return fmt.Errorf("endpoint must be host or host:port: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Endpoint strings like 'hiveserver:notaport' where SplitHostPort succeeds (host='hiveserver', port='notaport') and strconv.Atoi fails; also IPv6 literals like '[::1]:xyz' with non-numeric ports.

Common situations: Environment-variable endpoints with placeholders (HOST:PORT left literal); secrets/config mixups where a password fragment landed in the port field; sloppy CSV endpoint lists.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/dccf32a0cdf99849. Report an issue: GitHub.