{"record":{"id":"393e0fbc500066cf","repo":"jackc/pgx","slug":"unknown-startup-message-code-d","errorCode":null,"errorMessage":"unknown startup message code: %d","messagePattern":"unknown startup message code: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/backend.go","lineNumber":165,"sourceCode":"\t\terr = b.sslRequest.Decode(buf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &b.sslRequest, nil\n\tcase cancelRequestCode:\n\t\terr = b.cancelRequest.Decode(buf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &b.cancelRequest, nil\n\tcase gssEncReqNumber:\n\t\terr = b.gssEncRequest.Decode(buf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &b.gssEncRequest, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown startup message code: %d\", code)\n\t}\n}\n\n// Receive receives a message from the frontend. The returned message is only valid until the next call to Receive.\nfunc (b *Backend) Receive() (FrontendMessage, error) {\n\tif !b.partialMsg {\n\t\theader, err := b.cr.Next(5)\n\t\tif err != nil {\n\t\t\treturn nil, translateEOFtoErrUnexpectedEOF(err)\n\t\t}\n\n\t\tb.msgType = header[0]\n\n\t\tmsgLength := int(int32(binary.BigEndian.Uint32(header[1:])))\n\t\tif msgLength < 4 {\n\t\t\treturn nil, fmt.Errorf(\"invalid message length: %d\", msgLength)\n\t\t}\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/backend.go#L147-L183","documentation":"The first message from the client has a protocol code that does not correspond to any known startup message (startup, SSLRequest, CancelRequest, GSSEncRequest). The %d is the unrecognized code.","triggerScenarios":"Thrown at pgproto3/backend.go:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the client sends a valid protocol version code (e.g. 196608 for 3.0)","Check for SSLRequest (80877103) or CancelRequest (80877102) codes if applicable","Ensure no extra bytes precede the startup message","Use pgproto3 library functions to construct valid startup messages"],"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"}