go-sql-driver/mysql · error

invalid bool value: %s

Error message

invalid bool value: %s

What it means

Error "invalid bool value: %s" thrown in go-sql-driver/mysql.

Source

Thrown at dsn.go:498

}

// parseDSNParams parses the DSN "query string"
// Values must be url.QueryEscape'ed
func parseDSNParams(cfg *Config, params string) (err error) {
	for v := range strings.SplitSeq(params, "&") {
		key, value, found := strings.Cut(v, "=")
		if !found {
			continue
		}

		// cfg params
		switch key {
		// Disable INFILE allowlist / enable all files
		case "allowAllFiles":
			var isBool bool
			cfg.AllowAllFiles, isBool = readBool(value)
			if !isBool {
				return errors.New("invalid bool value: " + value)
			}

		// Use cleartext authentication mode (MySQL 5.5.10+)
		case "allowCleartextPasswords":
			var isBool bool
			cfg.AllowCleartextPasswords, isBool = readBool(value)
			if !isBool {
				return errors.New("invalid bool value: " + value)
			}

		// Allow fallback to unencrypted connection if server does not support TLS
		case "allowFallbackToPlaintext":
			var isBool bool
			cfg.AllowFallbackToPlaintext, isBool = readBool(value)
			if !isBool {
				return errors.New("invalid bool value: " + value)
			}

View on GitHub (pinned to 03d76c7e07)

Solutions

  1. Use a valid boolean literal for the DSN parameter: 'true' or 'false' (case-sensitive as parsed by the driver).
  2. Quote or escape the value if it contains characters that break DSN parsing.

Example fix

dsn := "user:pass@tcp(127.0.0.1:3306)/mydb?allowCleartextPasswords=true"

When it happens

Trigger: A boolean DSN parameter (e.g. allowAllFiles, allowCleartextPasswords, parseTime, multiStatements) is given a value that readBool cannot parse as true or false.

Common situations: Values like 'yes', 'on', or '2' are not accepted; only 'true'/'false' (and '1'/'0') are valid. Fix the parameter value in the DSN, e.g. 'parseTime=true'.


AI-assisted analysis of go-sql-driver/mysql@03d76c7e07 (2026-08-07). Data as JSON: /api/errors/2594004896d2640b. Report an issue: GitHub.