jackc/pgx · error
startup message too short
Error message
startup message too short
What it means
Error "startup message too short" thrown in jackc/pgx.
Source
Thrown at pgproto3/startup_message.go:32
ProtocolVersion30 = 196608 // 3.0
ProtocolVersion32 = 196610 // 3.2
ProtocolVersionLatest = ProtocolVersion32 // Latest is 3.2
ProtocolVersionNumber = ProtocolVersion30 // Default is still 3.0
)
type StartupMessage struct {
ProtocolVersion uint32
Parameters map[string]string
}
// Frontend identifies this message as sendable by a PostgreSQL frontend.
func (*StartupMessage) Frontend() {}
// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
// type identifier and 4 byte message length.
func (dst *StartupMessage) Decode(src []byte) error {
if len(src) < 4 {
return errors.New("startup message too short")
}
dst.ProtocolVersion = binary.BigEndian.Uint32(src)
rp := 4
if dst.ProtocolVersion != ProtocolVersion30 && dst.ProtocolVersion != ProtocolVersion32 {
return fmt.Errorf("Bad startup message version number. Expected %d or %d, got %d", ProtocolVersion30, ProtocolVersion32, dst.ProtocolVersion)
}
dst.Parameters = make(map[string]string)
for {
idx := bytes.IndexByte(src[rp:], 0)
if idx < 0 {
return &invalidMessageFormatErr{messageType: "StartupMessage"}
}
key := string(src[rp : rp+idx])
rp += idx + 1
View on GitHub (pinned to ec1a0befd2)
When it happens
Trigger: Thrown at pgproto3/startup_message.go:32 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /data/errors/021c4fdd2ad34531.json.
Report an issue: GitHub.