t8y2/dbx · error

invalid requesttimeout: %w

Error message

invalid requesttimeout: %w

What it means

The Cassandra driver's URL parser (applyCassandraURLParams) accepts 'requesttimeout' or 'timeout' query parameters and parses them with parseDurationOption. When the value is not a valid duration (or an unsupported duration format), the parse error is wrapped in this message. The URL is rejected and no Cassandra session/config is produced.

Source

Thrown at agents/drivers/cassandra-go/config.go:172

		return nil, fmt.Errorf("invalid Cassandra URL parameters: %w", err)
	}
	return values, nil
}

func applyCassandraURLParams(config *cassandraConfig, params url.Values) error {
	for rawKey, values := range params {
		if len(values) == 0 {
			continue
		}
		key := normalizeOptionName(rawKey)
		value := strings.TrimSpace(values[len(values)-1])
		switch key {
		case "localdatacenter", "datacenter", "dc":
			config.localDatacenter = value
		case "requesttimeout", "timeout":
			duration, err := parseDurationOption(value)
			if err != nil {
				return fmt.Errorf("invalid requesttimeout: %w", err)
			}
			config.requestTimeout = duration
		case "connecttimeout", "logintimeout":
			duration, err := parseDurationOption(value)
			if err != nil {
				return fmt.Errorf("invalid connecttimeout: %w", err)
			}
			config.connectTimeout = duration
		case "protocolversion", "protoversion":
			version, err := strconv.Atoi(value)
			if err != nil || version < 3 || version > 5 {
				return fmt.Errorf("protocolversion must be between 3 and 5")
			}
			config.protocolVersion = version
		case "consistency":
			if _, err := gocql.ParseConsistencyWrapper(value); err != nil {
				return err
			}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Fix the requesttimeout/timeout value in the URL to a valid duration like 5s, 500ms, or 1m (parseDurationOption format).
  2. Remove the timeout parameter entirely to use the driver's default timeout.
  3. If the value comes from an environment variable or template, validate it with time.ParseDuration-style parsing before interpolating into the URL.

Example fix

// before
cassandra://host:9042?keyspace=ks&requesttimeout=5000
// after
cassandra://host:9042?keyspace=ks&requesttimeout=5s
Defensive patterns

Strategy: validation

Validate before calling

func validDuration(v string) error {
	_, err := time.ParseDuration(v)
	return err
}
if err := validDuration(reqTimeout); err != nil {
	return fmt.Errorf("requesttimeout must be like 5s/500ms: %w", err)
}

Try / catch

cfg, err := parseCassandraConfig(dsn)
if err != nil {
	var msg string
	if strings.Contains(err.Error(), "invalid requesttimeout") {
		msg = "check requesttimeout/timeout query param (use e.g. 5s)"
	}
	return fmt.Errorf("cassandra DSN rejected: %v: %s", err, msg)
}

Prevention

When it happens

Trigger: Calling parseCassandraConfig on a cassandra:// URL whose query string contains requesttimeout=<value> (or timeout=<value>) where the value fails parseDurationOption, e.g. requesttimeout=abc, requesttimeout=5, or requesttimeout=5secs.

Common situations: Hand-edited DSNs with typo'd units (5000ms written as '5000' or '5sec'), values copy-pasted from Java/C# drivers that use different duration syntax, or config generated by scripts that interpolate empty or malformed values.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


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