googleapis/mcp-toolbox · error
sql.Open: %w
Error message
sql.Open: %w
What it means
initSingleStoreConnectionPool wraps sql.Open errors with this message. sql.Open validates the driver name and performs minimal DSN parsing; a failure here means the DSN built from the config (user, password, host, port, database, connection params) is malformed or the mysql driver is not registered.
Source
Thrown at internal/sources/singlestore/singlestore.go:219
connectionParams.Set("readTimeout", timeout.String())
}
// Custom user parameters (e.g. tls, compress) — may override defaults above.
for k, v := range cfg.ConnectionParams {
if v == "" {
continue // skip empty values
}
connectionParams.Set(k, v)
}
dsn := mysqlCfg.FormatDSN()
if enc := connectionParams.Encode(); enc != "" {
dsn += "&" + enc
}
// Interact with the driver directly as you normally would
pool, err := sql.Open("mysql", dsn)
if err != nil {
return nil, fmt.Errorf("sql.Open: %w", err)
}
return pool, nil
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Check the wrapped error for the exact DSN parse failure point.
- URL-escape special characters in the password or change it to an alphanumeric value temporarily.
- Validate connectionParams keys/values; remove exotic or duplicated params one at a time to isolate the offender.
- Confirm host/port formatting (no scheme, no trailing slash) in the source config.
- Ensure go-sql-driver/mysql is imported/registered (it is in this build; a custom binary build may lack it).
Example fix
// before (unescaped password with @) password: p@ss word // after password: "p%40ss%20word" # or change password to avoid special chars
Defensive patterns
Strategy: validation
Validate before calling
// Validate DSN-relevant fields before Initialize
func validateSSConfig(cfg Config) error {
if cfg.Host == "" { return errors.New("host required") }
if strings.ContainsAny(cfg.Password, "@/ ") { return errors.New("password contains DSN-unsafe chars; URL-escape it") }
for k := range cfg.ConnectionParams {
if strings.ContainsAny(k, "=& ") { return fmt.Errorf("invalid connection param key %q", k) }
}
return nil
} Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil && strings.Contains(err.Error(), "sql.Open:") {
return fmt.Errorf("DSN invalid — check host/port/password escaping/params: %w", err)
} Prevention
- URL-escape special characters in passwords
- Keep connection params simple and documented
- Verify with the mysql CLI before wiring config
- Avoid stray whitespace in config fields
When it happens
Trigger: Malformed DSN caused by bad config values (unescaped characters in password, invalid connectionParams keys/values, bad host format) or, rarely, the mysql driver failing to register.
Common situations: Passwords containing special characters like @ or / without URL-escaping, invalid characters in connection params that break the encoded query string, empty host, or stray whitespace in config fields.
Related errors
- invalid queryTimeout %q: %w
- doc %d: unexpected non-string key in input: %v
- doc %d: invalid config format at key %q: %w
- doc %d: invalid config format at key %q: expected nested for
- %s missing 'kind' field or it is not a string
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/8000898886cc1af8.
Report an issue: GitHub.