{"id":"021c4fdd2ad34531","repo":"jackc/pgx","slug":"startup-message-too-short","errorCode":null,"errorMessage":"startup message too short","messagePattern":"startup message too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/startup_message.go","lineNumber":32,"sourceCode":"\tProtocolVersion30     = 196608            // 3.0\n\tProtocolVersion32     = 196610            // 3.2\n\tProtocolVersionLatest = ProtocolVersion32 // Latest is 3.2\n\tProtocolVersionNumber = ProtocolVersion30 // Default is still 3.0\n)\n\ntype StartupMessage struct {\n\tProtocolVersion uint32\n\tParameters      map[string]string\n}\n\n// Frontend identifies this message as sendable by a PostgreSQL frontend.\nfunc (*StartupMessage) Frontend() {}\n\n// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message\n// type identifier and 4 byte message length.\nfunc (dst *StartupMessage) Decode(src []byte) error {\n\tif len(src) < 4 {\n\t\treturn errors.New(\"startup message too short\")\n\t}\n\n\tdst.ProtocolVersion = binary.BigEndian.Uint32(src)\n\trp := 4\n\n\tif dst.ProtocolVersion != ProtocolVersion30 && dst.ProtocolVersion != ProtocolVersion32 {\n\t\treturn fmt.Errorf(\"Bad startup message version number. Expected %d or %d, got %d\", ProtocolVersion30, ProtocolVersion32, dst.ProtocolVersion)\n\t}\n\n\tdst.Parameters = make(map[string]string)\n\tfor {\n\t\tidx := bytes.IndexByte(src[rp:], 0)\n\t\tif idx < 0 {\n\t\t\treturn &invalidMessageFormatErr{messageType: \"StartupMessage\"}\n\t\t}\n\t\tkey := string(src[rp : rp+idx])\n\t\trp += idx + 1\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/startup_message.go#L14-L50","documentation":"Error \"startup message too short\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgproto3/startup_message.go:32 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}