{"id":"8e6b30fba2f86e48","repo":"jackc/pgx","slug":"not-a-string-and-cannot-be-encoded-as-text","errorCode":null,"errorMessage":"not a string and cannot be encoded as text","messagePattern":"not a string and cannot be encoded as text","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"values.go","lineNumber":51,"sourceCode":"\t\t\targBuf = argBuf2\n\t\t} else {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif argBuf != nil {\n\t\tbuf = argBuf\n\t\tpgio.SetInt32(buf[sp:], int32(len(buf[sp:])-4))\n\t}\n\treturn buf, nil\n}\n\nfunc tryScanStringCopyValueThenEncode(m *pgtype.Map, buf []byte, oid uint32, arg any) ([]byte, error) {\n\ts, ok := arg.(string)\n\tif !ok {\n\t\ttextBuf, err := m.Encode(oid, TextFormatCode, arg, nil)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"not a string and cannot be encoded as text\")\n\t\t}\n\t\ts = string(textBuf)\n\t}\n\n\tvar v any\n\terr := m.Scan(oid, TextFormatCode, []byte(s), &v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m.Encode(oid, BinaryFormatCode, v, buf)\n}\n","sourceCodeStart":33,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/values.go#L33-L64","documentation":"Error \"not a string and cannot be encoded as text\" thrown in jackc/pgx.","triggerScenarios":"Thrown at values.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}