{"id":"feefdf6ebcf46d78","repo":"jackc/pgx","slug":"invalid-length-of-startup-packet-d","errorCode":null,"errorMessage":"invalid length of startup packet: %d","messagePattern":"invalid length of startup packet: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/backend.go","lineNumber":129,"sourceCode":"}\n\n// Untrace stops tracing.\nfunc (b *Backend) Untrace() {\n\tb.tracer = nil\n}\n\n// ReceiveStartupMessage receives the initial connection message. This method is used of the normal Receive method\n// because the initial connection message is \"special\" and does not include the message type as the first byte. This\n// will return either a StartupMessage, SSLRequest, GSSEncRequest, or CancelRequest.\nfunc (b *Backend) ReceiveStartupMessage() (FrontendMessage, error) {\n\tbuf, err := b.cr.Next(4)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmsgSize := int(int32(binary.BigEndian.Uint32(buf)) - 4)\n\n\tif msgSize < minStartupPacketLen || msgSize > maxStartupPacketLen {\n\t\treturn nil, fmt.Errorf(\"invalid length of startup packet: %d\", msgSize)\n\t}\n\n\tbuf, err = b.cr.Next(msgSize)\n\tif err != nil {\n\t\treturn nil, translateEOFtoErrUnexpectedEOF(err)\n\t}\n\n\tcode := binary.BigEndian.Uint32(buf)\n\n\tswitch code {\n\tcase ProtocolVersion30, ProtocolVersion32:\n\t\terr = b.startupMessage.Decode(buf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &b.startupMessage, nil\n\tcase sslRequestNumber:\n\t\terr = b.sslRequest.Decode(buf)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/backend.go#L111-L147","documentation":"Error \"invalid length of startup packet: %d\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgproto3/backend.go:129 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}