{"record":{"id":"415a8e32b5343df5","repo":"googleapis/mcp-toolbox","slug":"sql-open-w-415a8e","errorCode":null,"errorMessage":"sql.Open: %w","messagePattern":"sql\\.Open: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/mysql/mysql.go","lineNumber":232,"sourceCode":"\tfor k, v := range queryParams {\n\t\tif v == \"\" {\n\t\t\tcontinue // skip empty values\n\t\t}\n\t\tparams[k] = v\n\t}\n\tconfig.Params = params\n\n\tuserAgent, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfig.ConnectionAttributes = fmt.Sprintf(\"program_name:%s\", userAgent)\n\tdsn := config.FormatDSN()\n\n\t// Interact with the driver directly as you normally would\n\tpool, err := sql.Open(\"mysql\", dsn)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"sql.Open: %w\", err)\n\t}\n\treturn pool, nil\n}\n","sourceCodeStart":214,"sourceCodeEnd":236,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/mysql/mysql.go#L214-L236","documentation":"This error wraps a failure from database/sql's sql.Open when opening the MySQL connection pool. sql.Open validates the DSN produced by FormatDSN(); since the go-sql-driver defers connection to first use, a failure here is almost always a malformed DSN (bad config parameter, invalid net address format) or unknown driver registration, not a network problem.","triggerScenarios":"Initializing the mysql source with config values that produce an invalid DSN — e.g. malformed host/port characters, illegal characters in user/password/query parameters (unescaped @, /, or ()), or an invalid ConnectionAttributes value.","commonSituations":"Passwords containing special DSN characters (@, :, /, (, )) that were not escaped with AllowNativePasswords or url escaping, IPv6 literal hosts in brackets mis-formatted, empty required fields leaving a broken DSN, or query params injected with invalid keys.","solutions":["Inspect the wrapped error for the specific DSN parse message and fix the offending config field.","Escape special characters in user/password (or set allowNativePasswords=true and pass an empty password via the DSN-safe form).","Verify host and port formatting (hostname:port; IPv6 as [::1]:3306).","Log or print the formatted DSN locally (with secrets redacted) using go-sql-driver/mysql's mysql.Config.FormatDSN to see exactly what is generated.","Confirm the mysql driver import (blank import of the driver package) is present so the 'mysql' driver is registered."],"exampleFix":"// before\nuser: 'p@ss word'\n// after (escape DSN-special characters, or enable native passwords)\nuser: 'appuser'\npassword: 'p@ss word'\nallowNativePasswords: true","handlingStrategy":"validation","validationCode":"func validateMySQLConfig(user, pass, host, port string) error {\n    // DSN-special characters must be escaped or handled via allowNativePasswords\n    for name, v := range map[string]string{\"user\": user, \"password\": pass, \"host\": host, \"port\": port} {\n        if strings.ContainsAny(v, \"@:/(\") {\n            return fmt.Errorf(\"%s contains DSN-special characters (@ : / ( ) that must be escaped\", name)\n        }\n    }\n    if _, err := strconv.Atoi(port); err != nil {\n        return fmt.Errorf(\"port %q is not numeric\", port)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Escape or avoid DSN-special characters (@ : / ( )) in user, password, and query params; prefer allowNativePasswords for complex passwords.","Validate host/port formats early (hostname:port; IPv6 wrapped in brackets).","Dry-run the DSN locally with mysql.Config{...}.FormatDSN() and a minimal sql.Open ping before deploying.","Keep the blank driver import (_ \"github.com/go-sql-driver/mysql\") so the 'mysql' driver name is registered."],"tags":["mysql","sql-open","configuration","dsn"],"backgroundTag":"invalid-dsn","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}