{"record":{"id":"6518c5f6c80848d0","repo":"jackc/pgx","slug":"authentication-method-requirement-q-failed-s","errorCode":null,"errorMessage":"authentication method requirement %q failed: %s","messagePattern":"authentication method requirement %q failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/require_auth.go","lineNumber":64,"sourceCode":"\nfunc (ra requireAuth) allows(m authMethod) bool {\n\treturn ra.allowed&(1<<m) != 0\n}\n\n// check returns an error if method m is not permitted by the policy. The reason is phrased to\n// follow libpq's \"authentication method requirement \\\"%s\\\" failed: %s\" form so users migrating\n// from libpq see familiar diagnostics.\nfunc (ra requireAuth) check(m authMethod) error {\n\tif ra.allows(m) {\n\t\treturn nil\n\t}\n\tvar reason string\n\tif m == authMethodNone {\n\t\treason = \"server did not complete authentication\"\n\t} else {\n\t\treason = fmt.Sprintf(\"server requested %s authentication\", authMethodNames[m])\n\t}\n\treturn fmt.Errorf(\"authentication method requirement %q failed: %s\", ra.raw, reason)\n}\n\n// parseRequireAuth parses the require_auth connection parameter with libpq-compatible semantics:\n// a comma-separated list of method names, optionally each prefixed with \"!\" to negate. Negated and\n// non-negated entries cannot be mixed; duplicate entries are rejected. An empty string yields a\n// permissive policy (all methods allowed, no authentication required).\nfunc parseRequireAuth(s string) (requireAuth, error) {\n\tra := requireAuth{raw: s}\n\n\tif s == \"\" {\n\t\tra.allowed = 1<<authMethodCount - 1\n\t\treturn ra, nil\n\t}\n\n\tfirst := true\n\tnegated := false\n\tfor part := range strings.SplitSeq(s, \",\") {\n\t\tmethod := strings.TrimSpace(part)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/require_auth.go#L46-L82","documentation":"The require_auth policy was violated: the server's chosen (or absent) authentication method is not in the allowed set. The reason string states whether the server skipped authentication entirely or requested a disallowed method. Mirrors libpq's require_auth diagnostics.","triggerScenarios":"Thrown at pgconn/require_auth.go:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Align the require_auth list with the server's actual auth method","If the server did not authenticate, fix pg_hba.conf to require auth","Remove or adjust the require_auth setting in the connection string","Check for typos in method names like scram-sha-256"],"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"}