{"id":"cfeb3ff95dc1b85d","repo":"jackc/pgx","slug":"invalid-oauth-error-response-from-server-w","errorCode":null,"errorMessage":"invalid OAuth error response from server: %w","messagePattern":"invalid OAuth error response from server: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/auth_oauth.go","lineNumber":54,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch m := msg.(type) {\n\tcase *pgproto3.AuthenticationOk:\n\t\treturn nil\n\tcase *pgproto3.AuthenticationSASLContinue:\n\t\t// Server sent error response in SASL continue\n\t\t// https://www.rfc-editor.org/rfc/rfc7628.html#section-3.2.2\n\t\t// https://www.rfc-editor.org/rfc/rfc7628.html#section-3.2.3\n\t\terrResponse := struct {\n\t\t\tStatus              string `json:\"status\"`\n\t\t\tScope               string `json:\"scope\"`\n\t\t\tOpenIDConfiguration string `json:\"openid-configuration\"`\n\t\t}{}\n\t\terr := json.Unmarshal(m.Data, &errResponse)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid OAuth error response from server: %w\", err)\n\t\t}\n\n\t\t// Per RFC 7628 section 3.2.3, we should send a SASLResponse which only contains \\x01.\n\t\t// However, since the connection will be closed anyway, we can skip this\n\t\treturn fmt.Errorf(\"OAuth authentication failed: %s\", errResponse.Status)\n\n\tcase *pgproto3.ErrorResponse:\n\t\treturn ErrorResponseToPgError(m)\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unexpected message type during OAuth auth: %T\", msg)\n\t}\n}\n","sourceCodeStart":36,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/auth_oauth.go#L36-L68","documentation":"Error \"invalid OAuth error response from server: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/auth_oauth.go:54 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}