{"id":"3f5dd2ff43a6afd5","repo":"go-sql-driver/mysql","slug":"strict-mode-has-been-removed-see-https-github-c","errorCode":null,"errorMessage":"strict mode has been removed. See https://github.com/go-sql-driver/mysql/wiki/strict-mode","messagePattern":"strict mode has been removed\\. See https://github\\.com/go-sql-driver/mysql/wiki/strict-mode","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"dsn.go","lineNumber":638,"sourceCode":"\t\t// Reject read-only connections\n\t\tcase \"rejectReadOnly\":\n\t\t\tvar isBool bool\n\t\t\tcfg.RejectReadOnly, isBool = readBool(value)\n\t\t\tif !isBool {\n\t\t\t\treturn errors.New(\"invalid bool value: \" + value)\n\t\t\t}\n\n\t\t// Server public key\n\t\tcase \"serverPubKey\":\n\t\t\tname, err := url.QueryUnescape(value)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid value for server pub key name: %v\", err)\n\t\t\t}\n\t\t\tcfg.ServerPubKey = name\n\n\t\t// Strict mode\n\t\tcase \"strict\":\n\t\t\tpanic(\"strict mode has been removed. See https://github.com/go-sql-driver/mysql/wiki/strict-mode\")\n\n\t\t// Dial Timeout\n\t\tcase \"timeout\":\n\t\t\tcfg.Timeout, err = time.ParseDuration(value)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t// TLS-Encryption\n\t\tcase \"tls\":\n\t\t\tboolValue, isBool := readBool(value)\n\t\t\tif isBool {\n\t\t\t\tif boolValue {\n\t\t\t\t\tcfg.TLSConfig = \"true\"\n\t\t\t\t} else {\n\t\t\t\t\tcfg.TLSConfig = \"false\"\n\t\t\t\t}\n\t\t\t} else if vl := strings.ToLower(value); vl == \"skip-verify\" || vl == \"preferred\" {","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/c426bd93799de0f0e094c8f0582872c529d0ed0a/dsn.go#L620-L656","documentation":"This is NOT a returned error — the `strict` DSN case at dsn.go:638 calls panic(). Strict mode (which turned MySQL warnings into Go errors) was removed from the driver years ago; retaining the parameter would silently mislead users, so the driver deliberately panics to surface the incompatibility. The message links the migration wiki.","triggerScenarios":"Any DSN containing `strict=true` (or `strict=false`) parsed via ParseDSN/FormatDSN/DSN parsing path of sql.Open. The handler unconditionally panics; there is no valid value for `strict`.","commonSituations":"Upgrading the go-sql-driver/mysql dependency in a project whose DSN was written against an old (pre-removal) version of the driver; copy-pasting a DSN from an outdated tutorial or Stack Overflow answer.","solutions":["Remove `strict=true` from the DSN entirely — the parameter no longer exists.","Handle data truncation/warnings in application code by checking errors returned from Exec/Query, or set sql_mode on the MySQL server (e.g. STRICT_TRANS_TABLES) to make the server reject bad data.","If you depended on strict behavior, validate inputs in Go before sending them to the database."],"exampleFix":"// before\nsql.Open(\"mysql\", \"u:p@tcp(127.0.0.1:3306)/db?strict=true\")\n// after\nsql.Open(\"mysql\", \"u:p@tcp(127.0.0.1:3306)/db\")","handlingStrategy":"validation","validationCode":"dsn := strings.ReplaceAll(dsn, \"strict=true&\", \"\")\ndsn = strings.ReplaceAll(dsn, \"strict=true\", \"\")\ndsn = strings.ReplaceAll(dsn, \"&strict=false\", \"\")\ndsn = strings.ReplaceAll(dsn, \"strict=false\", \"\")","typeGuard":null,"tryCatchPattern":"if r := recover(); r != nil {\n    if msg, _ := r.(string); strings.Contains(msg, \"strict mode\") {\n        // strip strict= and retry DSN parse\n    }\n}","preventionTips":["Audit DSNs after every driver upgrade for removed parameters.","Pin and review the driver CHANGELOG.","Store DSNs in config validated by a schema, not free text."],"tags":["config","dsn","breaking-change","panic"],"analyzedSha":"c426bd93799de0f0e094c8f0582872c529d0ed0a","analyzedAt":"2026-08-04T21:52:59.219Z","schemaVersion":2}