{"id":"37370aa6026aa288","repo":"go-sql-driver/mysql","slug":"invalid-bool-value-value","errorCode":null,"errorMessage":"invalid bool value: {value}","messagePattern":"invalid bool value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dsn.go","lineNumber":498,"sourceCode":"}\n\n// parseDSNParams parses the DSN \"query string\"\n// Values must be url.QueryEscape'ed\nfunc parseDSNParams(cfg *Config, params string) (err error) {\n\tfor v := range strings.SplitSeq(params, \"&\") {\n\t\tkey, value, found := strings.Cut(v, \"=\")\n\t\tif !found {\n\t\t\tcontinue\n\t\t}\n\n\t\t// cfg params\n\t\tswitch key {\n\t\t// Disable INFILE allowlist / enable all files\n\t\tcase \"allowAllFiles\":\n\t\t\tvar isBool bool\n\t\t\tcfg.AllowAllFiles, 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// Use cleartext authentication mode (MySQL 5.5.10+)\n\t\tcase \"allowCleartextPasswords\":\n\t\t\tvar isBool bool\n\t\t\tcfg.AllowCleartextPasswords, 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// Allow fallback to unencrypted connection if server does not support TLS\n\t\tcase \"allowFallbackToPlaintext\":\n\t\t\tvar isBool bool\n\t\t\tcfg.AllowFallbackToPlaintext, isBool = readBool(value)\n\t\t\tif !isBool {\n\t\t\t\treturn errors.New(\"invalid bool value: \" + value)\n\t\t\t}\n","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/c426bd93799de0f0e094c8f0582872c529d0ed0a/dsn.go#L480-L516","documentation":"While parsing the DSN query string, the 'allowAllFiles' key is read with readBool, which accepts only 1/true/TRUE/True/0/false/FALSE/False (utils.go:92). Any other value yields 'invalid bool value: <value>' at dsn.go:498. allowAllFiles disables the INFILE allowlist, allowing LOAD DATA LOCAL INFILE to read any file (security-sensitive).","triggerScenarios":"A DSN like '?allowAllFiles=yes', '?allowAllFiles=on', '?allowAllFiles=enable', or '?allowAllFiles=' (empty).","commonSituations":"Copying boolean conventions from another driver (postgres/yaml uses yes/no/on/off); an env var templated in as 'True' works but 'YES' does not; a trailing '=' from a config template.","solutions":["Use one of the accepted tokens: allowAllFiles=true (or 1/True/TRUE) / allowAllFiles=false (or 0/False/FALSE).","If the value comes from config, normalize it with a helper that maps yes/on/enable to 'true' and no/off/disable to 'false'.","Omit the param if you want the default (false) — LOAD DATA LOCAL INFILE stays restricted."],"exampleFix":"// before\ndsn := \"user@tcp(host:3306)/db?allowAllFiles=yes\"\n// after\ndsn := \"user@tcp(host:3306)/db?allowAllFiles=true\"","handlingStrategy":"validation","validationCode":"func validMySQLBool(v string) bool {\n    switch v {\n    case \"1\", \"true\", \"TRUE\", \"True\", \"0\", \"false\", \"FALSE\", \"False\":\n        return true\n    }\n    return false\n}\n// usage: if !validMySQLBool(val) { /* reject allowAllFiles value */ }","typeGuard":null,"tryCatchPattern":"if _, err := mysql.ParseDSN(dsn); err != nil && strings.Contains(err.Error(), \"invalid bool value\") {\n    // normalize the offending ?allowAllFiles=... token and rebuild\n}","preventionTips":["Remember the only accepted bool tokens are 1/true/TRUE/True/0/false/FALSE/False.","Normalize env/config booleans to 'true'/'false' at the config boundary.","Treat allowAllFiles as security-sensitive: prefer leaving it unset."],"tags":["go","mysql","dsn","config","load-data-infile","security"],"analyzedSha":"c426bd93799de0f0e094c8f0582872c529d0ed0a","analyzedAt":"2026-08-04T21:52:59.219Z","schemaVersion":2}