{"id":"ed3387da8ff2364d","repo":"jackc/pgx","slug":"hstore-pair-d-key-cannot-be-null","errorCode":null,"errorMessage":"hstore pair %d: key cannot be NULL","messagePattern":"hstore pair (.+?): key cannot be NULL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/hstore.go","lineNumber":208,"sourceCode":"\t// Each pair carries at minimum two int32 length headers (key, value). This bounds the\n\t// up-front make() against a malicious server claiming a huge pair count in a small message.\n\tpairCount := r.Count(8)\n\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"hstore: %w\", err)\n\t}\n\n\thstore := make(Hstore, pairCount)\n\t// one allocation for all *string, rather than one per string, just like text parsing\n\tvalueStrings := make([]string, pairCount)\n\n\tfor i := range pairCount {\n\t\tkeyBytes, keyNull := r.Value()\n\t\tvalueBytes, valueNull := r.Value()\n\t\tif err := r.Err(); err != nil {\n\t\t\treturn fmt.Errorf(\"hstore pair %d: %w\", i, err)\n\t\t}\n\t\tif keyNull {\n\t\t\treturn fmt.Errorf(\"hstore pair %d: key cannot be NULL\", i)\n\t\t}\n\n\t\tkey := string(keyBytes)\n\t\tif valueNull {\n\t\t\thstore[key] = nil\n\t\t} else {\n\t\t\tvalueStrings[i] = string(valueBytes)\n\t\t\thstore[key] = &valueStrings[i]\n\t\t}\n\t}\n\n\tif err := r.Finish(); err != nil {\n\t\treturn fmt.Errorf(\"hstore: %w\", err)\n\t}\n\treturn scanner.ScanHstore(hstore)\n}\n\ntype scanPlanTextAnyToHstoreScanner struct{}","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/hstore.go#L190-L226","documentation":"Error \"hstore pair %d: key cannot be NULL\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/hstore.go:208 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}