jackc/pgx · error

authType not recognized

Error message

authType not recognized: %d

What it means

The frontend told the backend to expect an authentication message type that pgproto3 does not recognize. Only the known AuthType* constants are accepted; the %d shows the rejected value.

Solutions

  1. Use one of the AuthType constants exported by pgproto3
  2. Verify the auth type value against the PostgreSQL protocol spec
  3. Ensure SetAuthType is called with the type from the received Authentication message
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgproto3/backend.go:285 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: /api/errors/b10c87a10d78ac8f. Report an issue: GitHub.

Appendix: source

Thrown at pgproto3/backend.go:285

//			the context.
//
// Since the Frontend does not know about the state of a backend, it is important
// to call SetAuthType() after an authentication request is received by the Frontend.
func (b *Backend) SetAuthType(authType uint32) error {
	switch authType {
	case AuthTypeOk,
		AuthTypeCleartextPassword,
		AuthTypeMD5Password,
		AuthTypeSCMCreds,
		AuthTypeGSS,
		AuthTypeGSSCont,
		AuthTypeSSPI,
		AuthTypeSASL,
		AuthTypeSASLContinue,
		AuthTypeSASLFinal:
		b.authType = authType
	default:
		return fmt.Errorf("authType not recognized: %d", authType)
	}

	return nil
}

// SetMaxBodyLen sets the maximum length of a message body in octets.
// If a message body exceeds this length, Receive will return an error.
// This is useful for protecting against malicious clients that send
// large messages with the intent of causing memory exhaustion.
// The default value is 0.
// If maxBodyLen is 0, then no maximum is enforced.
func (b *Backend) SetMaxBodyLen(maxBodyLen int) {
	b.maxBodyLen = maxBodyLen
}

View on GitHub (pinned to ec1a0befd2)