{"id":"11fcff33da22836a","repo":"jackc/pgx","slug":"expected-authenticationsaslfinal-message-but-recei","errorCode":null,"errorMessage":"expected AuthenticationSASLFinal message but received unexpected message %T","messagePattern":"expected AuthenticationSASLFinal message but received unexpected message %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/auth_scram.go","lineNumber":141,"sourceCode":"\t\treturn nil, ErrorResponseToPgError(m)\n\t}\n\n\treturn nil, fmt.Errorf(\"expected AuthenticationSASLContinue message but received unexpected message %T\", msg)\n}\n\nfunc (c *PgConn) rxSASLFinal() (*pgproto3.AuthenticationSASLFinal, error) {\n\tmsg, err := c.receiveMessage()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch m := msg.(type) {\n\tcase *pgproto3.AuthenticationSASLFinal:\n\t\treturn m, nil\n\tcase *pgproto3.ErrorResponse:\n\t\treturn nil, ErrorResponseToPgError(m)\n\t}\n\n\treturn nil, fmt.Errorf(\"expected AuthenticationSASLFinal message but received unexpected message %T\", msg)\n}\n\ntype scramClient struct {\n\tserverAuthMechanisms []string\n\tpassword             string\n\tclientNonce          []byte\n\n\t// authMechanism is the selected SASL mechanism for the client. Must be\n\t// either SCRAM-SHA-256 (default) or SCRAM-SHA-256-PLUS.\n\t//\n\t// Upgraded to SCRAM-SHA-256-PLUS during authentication when channel binding\n\t// is not disabled, channel binding data is available (TLS connection with\n\t// an obtainable server certificate hash) and the server advertises\n\t// SCRAM-SHA-256-PLUS.\n\tauthMechanism string\n\n\t// hasTLS indicates whether the connection is using TLS. This is\n\t// needed because the GS2 header must distinguish between a client that","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/auth_scram.go#L123-L159","documentation":"Error \"expected AuthenticationSASLFinal message but received unexpected message %T\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/auth_scram.go:141 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}