{"record":{"id":"3d71b1e0a3cc2b8f","repo":"argoproj/argo-workflows","slug":"failed-to-create-mysql-connector-w","errorCode":null,"errorMessage":"failed to create mysql connector: %w","messagePattern":"failed to create mysql connector: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/sqldb/sqldb.go","lineNumber":295,"sourceCode":"\tparsedCfg, err := mysql.ParseDSN(mysqlCfg.FormatDSN())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid MySQL config options: %w\", err)\n\t}\n\treturn parsedCfg, nil\n}\n\nfunc createMySQLDBSessionWithCreds(cfg *config.MySQLConfig, persistPool *config.ConnectionPool, username, password string, connectTimeout time.Duration) (db.Session, error) {\n\tmysqlCfg, err := buildMySQLConfig(cfg, username, password, connectTimeout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Wrap the MySQL connector so Connect (dial + handshake read) is bounded by\n\t// connectTimeout, protecting against a half-open server the same way lib/pq's\n\t// connect_timeout protects PostgreSQL.\n\tconnector, err := mysql.NewConnector(mysqlCfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create mysql connector: %w\", err)\n\t}\n\twrapped := &timeoutConnector{Connector: connector, timeout: connectTimeout}\n\n\t// Create traced *sql.DB using otelsql\n\tsqlDB := otelsql.OpenDB(wrapped, otelSQLOptions(semconv.DBSystemNameMySQL, cfg.Database)...)\n\n\t// Wrap with upper/db\n\tsession, err := mysqladp.New(sqlDB)\n\tif err != nil {\n\t\tsqlDB.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create upper/db session: %w\", err)\n\t}\n\n\tsession = ConfigureDBSession(session, persistPool)\n\n\t// this is needed to make MySQL run in a Golang-compatible UTF-8 character set.\n\t_, err = session.SQL().Exec(\"SET NAMES 'utf8mb4'\")\n\tif err != nil {","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/sqldb/sqldb.go#L277-L313","documentation":"Returned when mysql.NewConnector(mysqlCfg) fails while building a MySQL database session. mysql.NewConnector rarely fails — it validates the mysql.Config — so this indicates the driver rejected the config object itself (e.g. invalid Net/Addr combination or nil config) before any network dial is attempted. The connector is subsequently wrapped in a timeoutConnector so Connect() is bounded by connectTimeout.","triggerScenarios":"createMySQLDBSessionWithCreds calls mysql.NewConnector with a *mysql.Config that go-sql-driver considers invalid — practically only reachable with an empty/nil config or invalid Net ('tcp','unix','cloudsql' rules violated), since DSN-level issues were caught earlier by ParseDSN round-trip.","commonSituations":"Programmatic callers constructing MySQLConfig with a blank address or unknown network type; custom integrations calling CreateDBSessionWithCreds with zero-valued config; misconfigured 'protocol'/'address' pairs (e.g. unix socket path that is empty).","solutions":["Inspect the wrapped error and the mysql.Config fields (Net, Addr) built from your MySQLConfig; ensure a valid protocol/address pair (tcp:host:port or unix:/path/to/socket).","Set host and port explicitly in the mysql section of the controller config and retry.","If running in k8s, confirm the configmap mounted for the controller has the mysql block populated and not empty.","Update go-sql-driver/mysql if a config combination previously valid now fails validation."],"exampleFix":"// before (empty address)\nmysql:\n  host: \"\"\n// after\nmysql:\n  host: mysql.mysql.svc\n  port: 3306","handlingStrategy":"validation","validationCode":"if cfg == nil || cfg.Host == \"\" { return errors.New(\"mysql config incomplete: host is required\") }\n// valid Net combos: \"tcp\",\"tcp4\",\"tcp6\",\"unix\",\"cloudsql\"","typeGuard":null,"tryCatchPattern":"session, err := CreateDBSessionWithCreds(ctx)\nif err != nil && strings.Contains(err.Error(), \"failed to create mysql connector\") {\n    logger.Error(ctx, \"mysql connector construction failed — check Net/Addr config\", err)\n    return err\n}","preventionTips":["Always set host and port explicitly in the mysql config block.","Don't construct MySQLConfig programmatically with zero values.","Verify network type assumptions (unix sockets need a valid socket path)."],"tags":["database","mysql","connection","connector"],"backgroundTag":"invalid-database-config","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}