t8y2/dbx · error

parse IoTDB connection string: %w

Error message

parse IoTDB connection string: %w

What it means

parseConnectionConfig parses the IoTDB connection string: it strips an optional 'jdbc:' prefix and runs url.Parse. If URL parsing fails, the error is wrapped as 'parse IoTDB connection string: %w'. This surfaces malformed connection strings early.

Source

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

	if config.Host == "" {
		config.Host = "127.0.0.1"
	}
	if config.Port <= 0 {
		config.Port = defaultIoTDBPort
	}
	if config.Username == "" {
		config.Username = "root"
	}
	if config.Password == "" {
		config.Password = "root"
	}

	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
			}

View on GitHub (pinned to c0390bff16)

Solutions

  1. URL-encode the username/password (url.QueryEscape) before composing the string
  2. Validate the connection string with url.Parse in your own code before passing it
  3. Remove spaces/invalid characters; bracket IPv6 hosts
  4. Log the normalized (jdbc-stripped) string that failed to confirm the syntax problem

Example fix

// before
connStr := fmt.Sprintf("iotdb://%s:%s@host:6667", user, password) // password has '@'
// after
connStr := fmt.Sprintf("iotdb://%s:%s@host:6667", url.QueryEscape(user), url.QueryEscape(password))
Defensive patterns

Strategy: validation

Validate before calling

func validateIoTDBConnStr(raw string) error {
  normalized := strings.TrimPrefix(strings.TrimSpace(raw), "jdbc:")
  if _, err := url.Parse(normalized); err != nil {
    return fmt.Errorf("invalid connection string: %w", err)
  }
  return nil
}

Prevention

When it happens

Trigger: Passing a ConnectionString with invalid URL syntax — e.g. unescaped characters, mismatched brackets in IPv6 host, or a ':' only host:port fragment like 'host:' — to newServer.

Common situations: Building the string by concatenation with an unencoded password containing '@' or ':'; forgetting jdbc: prefix handling and embedding spaces; IPv6 addresses without brackets.

Related errors


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