t8y2/dbx · error

invalid Hive connection string: %w

Error message

invalid Hive connection string: %w

What it means

parseHiveConnection accepts either a JDBC-style 'jdbc:hive2://' URL, a plain 'hive://' URL, or host[:port][/db] syntax. When the value uses hive:// but Go's url.Parse cannot parse it, the function wraps the parse failure with this error and aborts connection setup before any network call.

Source

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

func newParsedHiveConnection() parsedHiveConnection {
	return parsedHiveConnection{
		parameters: map[string]string{},
		hiveConfs:  map[string]string{},
		hiveVars:   map[string]string{},
	}
}

func parseHiveConnectionString(raw string) (parsedHiveConnection, error) {
	value := strings.TrimSpace(raw)
	if value == "" {
		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 {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Fix the hive:// URL syntax (percent-encode special characters, balance [ ] for IPv6 hosts)
  2. Use the jdbc:hive2:// prefix form or plain host:port syntax which avoids url.Parse
  3. Print/inspect the wrapped cause (%w) to see the exact url.Parse complaint
  4. Validate the connection string before passing it to the driver

Example fix

// before
url := "hive://user:p@ss[w ord@host:10000"
// after
url := "hive://user:p%40ss%5Bw%20ord@host:10000/default"
Defensive patterns

Strategy: validation

Validate before calling

if strings.HasPrefix(strings.ToLower(dsn), "hive://") {
    if _, err := url.Parse(dsn); err != nil {
        return fmt.Errorf("bad hive DSN: %w", err)
    }
}

Try / catch

conn, err := ParseHiveConnection(dsn)
if err != nil {
    if strings.Contains(err.Error(), "invalid Hive connection string") {
        return fmt.Errorf("check hive:// URL syntax (percent-encode specials): %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Passing a connection string starting with hive:// that is malformed — e.g. hive://%zz, unbalanced brackets in an IPv6 literal, or control characters — so url.Parse returns an error.

Common situations: Hand-edited DSNs with unencoded special characters in password or database segments; copy-pasted URLs that were truncated; templated configs where a variable expanded to something with stray '://'.

Related errors


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