{"record":{"id":"06b9f48c51c7d67f","repo":"jackc/pgx","slug":"cannot-scan-empty-string-into-t","errorCode":null,"errorMessage":"cannot scan empty string into %T","messagePattern":"cannot scan empty string into %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/bool.go","lineNumber":273,"sourceCode":"\tp, ok := (dst).(*bool)\n\tif !ok {\n\t\treturn ErrScanTargetTypeChanged\n\t}\n\n\t*p = src[0] == 1\n\n\treturn nil\n}\n\ntype scanPlanTextAnyToBool struct{}\n\nfunc (scanPlanTextAnyToBool) Scan(src []byte, dst any) error {\n\tif src == nil {\n\t\treturn fmt.Errorf(\"cannot scan NULL into %T\", dst)\n\t}\n\n\tif len(src) == 0 {\n\t\treturn fmt.Errorf(\"cannot scan empty string into %T\", dst)\n\t}\n\n\tp, ok := (dst).(*bool)\n\tif !ok {\n\t\treturn ErrScanTargetTypeChanged\n\t}\n\n\tv, err := planTextToBool(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*p = v\n\n\treturn nil\n}\n\ntype scanPlanBinaryBoolToBoolScanner struct{}","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/bool.go#L255-L291","documentation":"Text bool scan plan got a zero-length, non-NULL source. An empty string cannot be interpreted as a PostgreSQL boolean, unlike valid representations like 't', 'true', '1'.","triggerScenarios":"Thrown at pgtype/bool.go:273 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Store/emit a real boolean representation ('t','true','yes','1','f','false','no','0')","Treat empty strings as NULL before scanning, if that matches your data","Fix upstream data production that created empty boolean text"],"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"}