t8y2/dbx · error

invalid usekrb5 option: %w

Error message

invalid usekrb5 option: %w

What it means

Returned by applyCassandraURLParams in the cassandra-go driver when the usekrb5 URL parameter cannot be parsed as a boolean by strconv (e.g. usekrb5=yes123). The parse error is wrapped with the 'invalid usekrb5 option' context; connection string parsing aborts.

Source

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

			if err != nil {
				return fmt.Errorf("invalid disableinitialhostlookup option: %w", err)
			}
			config.disableInitialHostLookup = disabled
		case "loadbalancing":
			policy, err := normalizeLoadBalancingPolicy(value)
			if err != nil {
				return err
			}
			config.loadBalancingPolicy = policy
		case "sslenginefactory":
			if value != "" && !strings.EqualFold(simpleClassName(value), "DefaultSslEngineFactory") {
				return fmt.Errorf("custom Cassandra sslenginefactory is not supported by the native agent: %s", value)
			}
			config.ssl = true
		case "usekrb5":
			enabled, err := strconv.ParseBool(value)
			if err != nil {
				return fmt.Errorf("invalid usekrb5 option: %w", err)
			}
			config.kerberos.enabled = enabled
		case "secureconnectbundle":
			config.secureConnectBundle = value
		case "configfile":
			config.configFile = value
		case "kerberosconfig", "kerberosconfigpath", "krb5config", "krb5conf":
			config.kerberos.configPath = value
		case "jaasconfig", "jaasconfigpath":
			config.kerberos.jaasConfigPath = value
		case "kerberosprincipal", "krb5principal":
			config.kerberos.principal = value
		case "kerberosrealm", "krb5realm":
			config.kerberos.realm = value
		case "kerberoskeytab", "keytab":
			config.kerberos.keytabPath = value
		case "kerberosccache", "kerberosticketcache", "ccache", "ticketcache":
			config.kerberos.ccachePath = value

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use true/1 or false/0 (or t/f case variants) for usekrb5
  2. Remove usekrb5 if Kerberos is not needed
  3. Check that any env-substituted value in the DSN actually renders as a boolean

Example fix

// before
cassandra://127.0.0.1/myks?usekrb5=YES
// after
cassandra://127.0.0.1/myks?usekrb5=true
Defensive patterns

Strategy: validation

Validate before calling

if v := q.Get("usekrb5"); v != "" {
	if _, err := strconv.ParseBool(v); err != nil {
		return errors.New("usekrb5 must be a boolean")
	}
}

Try / catch

if err := parseCassandraConfig(dsn); err != nil {
	if strings.Contains(err.Error(), "usekrb5 option") {
		return normalizeBoolParams(dsn) // rewrite yes/on -> true
	}
	return err
}

Prevention

When it happens

Trigger: DSN contains usekrb5=<value> where value is not one of strconv.ParseBool's accepted literals, e.g. usekrb5=YES or usekrb5=.

Common situations: Kerberos setup instructions copied from Java docs using 'yes'/'no'; shell variables expanding to empty strings in the URL; case/format mistakes in generated connection strings.

Related errors


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