{"record":{"id":"7d884bde86211356","repo":"jackc/pgx","slug":"unknown-boolean-string-representation-q","errorCode":null,"errorMessage":"unknown boolean string representation %q","messagePattern":"unknown boolean string representation %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/bool.go","lineNumber":344,"sourceCode":"\tv, err := planTextToBool(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn s.ScanBool(Bool{Bool: v, Valid: true})\n}\n\n// https://www.postgresql.org/docs/current/datatype-boolean.html\nfunc planTextToBool(src []byte) (bool, error) {\n\ts := string(bytes.ToLower(bytes.TrimSpace(src)))\n\n\tswitch {\n\tcase strings.HasPrefix(\"true\", s), strings.HasPrefix(\"yes\", s), s == \"on\", s == \"1\": //nolint:gocritic // s is intentionally the prefix argument so partial inputs (t, tr, tru) also match.\n\t\treturn true, nil\n\tcase strings.HasPrefix(\"false\", s), strings.HasPrefix(\"no\", s), strings.HasPrefix(\"off\", s), s == \"0\": //nolint:gocritic // s is intentionally the prefix argument so partial inputs (f, fa, fal) also match.\n\t\treturn false, nil\n\tdefault:\n\t\treturn false, fmt.Errorf(\"unknown boolean string representation %q\", src)\n\t}\n}\n","sourceCodeStart":326,"sourceCodeEnd":347,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/bool.go#L326-L347","documentation":"planTextToBool lowercases/trims the text and matches PostgreSQL's accepted boolean spellings (true/yes/on/1, false/no/off/0 and unique prefixes). Anything else — a misspelled or unrelated string — is rejected with the offending text quoted.","triggerScenarios":"Thrown at pgtype/bool.go:344 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of PostgreSQL's boolean representations: t/true/yes/on/1 or f/false/no/off/0","Clean or normalize the source data before it is treated as a bool","If the column is not boolean, fix the query/scan target mismatch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}