jackc/pgx · error

negative require_auth method %q cannot be mixed with non-neg

Error message

negative require_auth method %q cannot be mixed with non-negative methods

What it means

Error "negative require_auth method %q cannot be mixed with non-negative methods" thrown in jackc/pgx.

Source

Thrown at pgconn/require_auth.go:100

		method := strings.TrimSpace(part)

		neg := strings.HasPrefix(method, "!")
		if neg {
			method = method[1:]
		}
		if first {
			negated = neg
			if negated {
				// A negated list starts from "everything allowed, auth not required" and removes
				// methods; "!none" below flips authRequired back on.
				ra.allowed = 1<<authMethodCount - 1
			} else {
				ra.authRequired = true
			}
			first = false
		} else if neg != negated {
			if neg {
				return requireAuth{}, fmt.Errorf("negative require_auth method %q cannot be mixed with non-negative methods", method)
			}
			return requireAuth{}, fmt.Errorf("require_auth method %q cannot be mixed with negative methods", method)
		}

		var m authMethod
		switch method {
		case "password":
			m = authMethodPassword
		case "md5":
			m = authMethodMD5
		case "gss":
			m = authMethodGSS
		case "sspi":
			m = authMethodSSPI
		case "scram-sha-256":
			m = authMethodSCRAMSHA256
		case "oauth":
			m = authMethodOAuth

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgconn/require_auth.go:100 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/09d5cfd94728bccf.json. Report an issue: GitHub.