t8y2/dbx · error

invalid Hive port: %w

Error message

invalid Hive port: %w

What it means

When parsing a hive:// URL that contains an explicit port, the driver converts the port substring with strconv.Atoi; a non-numeric port wraps that error. This guarantees endpoints only ever get valid integer ports.

Source

Thrown at agents/drivers/argo-go/config.go:316

		return newParsedHiveConnection(), nil
	}
	if strings.HasPrefix(strings.ToLower(value), "jdbc:hive2://") {
		value = value[len("jdbc:hive2://"):]
	} else if strings.HasPrefix(strings.ToLower(value), "hive://") {
		parsedURL, err := url.Parse(value)
		if err != nil {
			return parsedHiveConnection{}, fmt.Errorf("invalid Hive connection string: %w", err)
		}
		result := newParsedHiveConnection()
		if parsedURL.User != nil {
			result.username = parsedURL.User.Username()
			result.password, _ = parsedURL.User.Password()
		}
		port := defaultHivePort
		if parsedURL.Port() != "" {
			parsedPort, err := strconv.Atoi(parsedURL.Port())
			if err != nil {
				return parsedHiveConnection{}, fmt.Errorf("invalid Hive port: %w", err)
			}
			port = parsedPort
		}
		result.endpoints = []endpoint{{Host: parsedURL.Hostname(), Port: port}}
		result.database = strings.Trim(parsedURL.Path, "/")
		for key, entries := range parsedURL.Query() {
			if len(entries) > 0 {
				setCaseInsensitive(result.parameters, key, entries[len(entries)-1])
			}
		}
		return result, nil
	} else {
		return parsedHiveConnection{}, errors.New("Hive connection string must start with jdbc:hive2:// or hive://")
	}

	result := newParsedHiveConnection()
	if fragment := strings.IndexByte(value, '#'); fragment >= 0 {
		result.hiveVars = parseHiveAssignments(value[fragment+1:], false)

View on GitHub (pinned to c0390bff16)

Solutions

  1. Correct the port in the URL to a plain integer, e.g. hive://host:10000/default
  2. Bracket IPv6 hosts: hive://[::1]:10000/default
  3. Omit the port entirely to use defaultHivePort
  4. Pre-validate with strconv.Atoi or url.Parse in your own config loader

Example fix

// before
url := "hive://myhost:10o000/default"
// after
url := "hive://myhost:10000/default"
Defensive patterns

Strategy: validation

Validate before calling

if u, err := url.Parse(connStr); err == nil && u.Port() != "" {
    if p, err := strconv.Atoi(u.Port()); err != nil || p < 1 || p > 65535 {
        return fmt.Errorf("port %q in %q must be 1-65535", u.Port(), connStr)
    }
}

Type guard

func validPort(s string) bool {
    p, err := strconv.Atoi(s)
    return err == nil && p >= 1 && p <= 65535
}

Try / catch

conn, err := parseHiveConnection(raw)
if err != nil && strings.Contains(err.Error(), "invalid Hive port") {
    return fmt.Errorf("check hive URL port syntax: %w", err)
}

Prevention

When it happens

Trigger: A hive:// URL whose port portion (parsedURL.Port()) is non-numeric, e.g. hive://host:abc/default or a path segment misinterpreted as a port after a malformed ':' delimiter.

Common situations: Typos in the port, pasting 'host:10000/default' with a stray colon, or IPv6 hosts written without brackets so SplitHostPort/Port() misparse the segments.

Related errors


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