{"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":"Error \"authentication method requirement %q failed: %s\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/require_auth.go:64 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}