{"record":{"id":"c3132b0f75cbad61","repo":"go-sql-driver/mysql","slug":"invalid-dsn-did-you-forget-to-escape-a-param-valu","errorCode":null,"errorMessage":"invalid DSN: did you forget to escape a param value?","messagePattern":"invalid DSN: did you forget to escape a param value\\?","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dsn.go","lineNumber":29,"sourceCode":"import (\n\t\"bytes\"\n\t\"context\"\n\t\"crypto/rsa\"\n\t\"crypto/tls\"\n\t\"errors\"\n\t\"fmt\"\n\t\"maps\"\n\t\"math/big\"\n\t\"net\"\n\t\"net/url\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar (\n\terrInvalidDSNUnescaped       = errors.New(\"invalid DSN: did you forget to escape a param value?\")\n\terrInvalidDSNAddr            = errors.New(\"invalid DSN: network address not terminated (missing closing brace)\")\n\terrInvalidDSNNoSlash         = errors.New(\"invalid DSN: missing the slash separating the database name\")\n\terrInvalidDSNUnsafeCollation = errors.New(\"invalid DSN: interpolateParams can not be used with unsafe collations\")\n)\n\n// Config is a configuration parsed from a DSN string.\n// If a new Config is created instead of being parsed from a DSN string,\n// the NewConfig function should be used, which sets default values.\ntype Config struct {\n\t// non boolean fields\n\n\tUser                 string            // Username\n\tPasswd               string            // Password (requires User)\n\tNet                  string            // Network (e.g. \"tcp\", \"tcp6\", \"unix\". default: \"tcp\")\n\tAddr                 string            // Address (default: \"127.0.0.1:3306\" for \"tcp\" and \"/tmp/mysql.sock\" for \"unix\")\n\tDBName               string            // Database name\n\tParams               map[string]string // Connection parameters\n\tConnectionAttributes string            // Connection Attributes, comma-delimited string of user-defined \"key:value\" pairs","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/03d76c7e07908e255ce62d126d07ede3f2365d86/dsn.go#L11-L47","documentation":"Error \"invalid DSN: did you forget to escape a param value?\" thrown in go-sql-driver/mysql.","triggerScenarios":"Parsing the DSN fails because a parameter value contains a reserved character (such as '/' or '?') that was not URL-escaped, so the parser misinterprets the DSN structure.","commonSituations":"Occurs when passwords or other DSN values contain special characters like '@', '/', ':', or '?'. Escape the value with url.QueryEscape or url.PathEscape, e.g. user:pa%40ss@tcp(host)/db.","solutions":["URL-escape special characters in DSN parameter values, e.g. replace '/' with %2F and '&' with %26 in passwords or other values.","Use url.QueryEscape (or the driver's Config.FormatDSN) to build the DSN instead of string concatenation."],"exampleFix":"cfg := mysql.NewConfig()\ncfg.User = \"user\"\ncfg.Passwd = \"p@ss/word\" // FormatDSN escapes it automatically\ncfg.Net = \"tcp\"\ncfg.Addr = \"127.0.0.1:3306\"\ncfg.DBName = \"mydb\"\ndsn := cfg.FormatDSN()","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03d76c7e07908e255ce62d126d07ede3f2365d86","analyzedAt":"2026-08-07T10:39:17.340Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}