t8y2/dbx · error

invalid IoTDB port: %s

Error message

invalid IoTDB port: %s

What it means

If the parsed URL carries a port, parseConnectionConfig converts it with strconv.Atoi and requires a strictly positive integer; otherwise it returns 'invalid IoTDB port: %s'. This prevents zero/negative/garbage ports reaching the dialer.

Source

Thrown at agents/drivers/iotdb/driver.go:128

	}

	query := url.Values{}
	if raw := strings.TrimSpace(params.ConnectionString); raw != "" {
		normalized := strings.TrimPrefix(raw, "jdbc:")
		parsed, err := url.Parse(normalized)
		if err != nil {
			return connectionConfig{}, fmt.Errorf("parse IoTDB connection string: %w", err)
		}
		if parsed.Scheme != "" && !strings.EqualFold(parsed.Scheme, "iotdb") {
			return connectionConfig{}, fmt.Errorf("unsupported IoTDB connection scheme: %s", parsed.Scheme)
		}
		if parsed.Hostname() != "" {
			config.Host = parsed.Hostname()
		}
		if parsed.Port() != "" {
			port, err := strconv.Atoi(parsed.Port())
			if err != nil || port <= 0 {
				return connectionConfig{}, fmt.Errorf("invalid IoTDB port: %s", parsed.Port())
			}
			config.Port = port
		}
		if parsed.User != nil {
			if username := parsed.User.Username(); username != "" {
				config.Username = username
			}
			if password, ok := parsed.User.Password(); ok {
				config.Password = password
			}
		}
		if database := strings.Trim(strings.TrimSpace(parsed.Path), "/"); database != "" {
			config.Database = database
		}
		query = parsed.Query()
	}
	if raw := strings.TrimSpace(params.URLParams); raw != "" {
		values, err := url.ParseQuery(strings.TrimPrefix(raw, "?"))

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use a numeric port 1-65535 in the connection string (IoTDB default RPC port is 6667)
  2. Render the port with strconv.Itoa before composing the string
  3. Check for leftover template placeholders or copied trailing characters

Example fix

// before
connStr := "iotdb://host:iotdb-rpc"
// after
connStr := fmt.Sprintf("iotdb://host:%d", 6667)
Defensive patterns

Strategy: validation

Validate before calling

func validatePort(p string) error {
  n, err := strconv.Atoi(p)
  if err != nil || n <= 0 || n > 65535 {
    return fmt.Errorf("port %q must be a numeric value in 1-65535", p)
  }
  return nil
}

Prevention

When it happens

Trigger: Connection strings like 'iotdb:host:0', 'iotdb:host:-1', or a non-numeric port such as 'iotdb:host:iotdb' or 'host:6667x'.

Common situations: Named service ports ('iotdb' service name instead of number) from /etc/services-style configs; trailing punctuation from copy-paste; template placeholder left unfilled like 'host:{port}'.

Related errors


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