fix: Show a clear notice when the OAuth provider is unavailable (#14845)

* fix: Show provider outage notice instead of reporting OAuth 5xx to Sentry

* trans
This commit is contained in:
Tom Moor authored and GitHub committed 2026-12-01 21:17:08 -05:00
1 parent ef5e37dc71
commit 307b385a98
3 files changed
+47 -9

No files matched your search

+25 -2
View File
@@ -2,8 +2,15 @@ import { WarningIcon } from "outline-icons";
import { Trans } from "react-i18next";
import Notice from "~/components/Notice";
import useQuery from "~/hooks/useQuery";
import useStores from "~/hooks/useStores";
function Message({ notice }: { notice: string }) {
function Message({
notice,
providerName,
}: {
notice: string;
providerName?: string;
}) {
switch (notice) {
case "invalid-code":
return (
@@ -68,6 +75,16 @@ function Message({ notice }: { notice: string }) {
try again in a few minutes.
</Trans>
);
case "provider-unavailable":
if (providerName) {
return (
<Trans
defaults="{{ providerName }} returned an error. This is a temporary problem with {{ providerName }}, please try again in a few minutes."
values={{ providerName }}
/>
);
}
// falls through
case "auth-error":
case "state-mismatch":
return (
@@ -127,15 +144,21 @@ function Message({ notice }: { notice: string }) {
export function Notices() {
const query = useQuery();
const { auth } = useStores();
const notice = query.get("notice");
// Resolve the name from config so that query text is never displayed.
const providerName = auth.config?.providers.find(
(provider) => provider.id === query.get("provider")
)?.name;
if (!notice) {
return null;
}
return (
<Notice icon={<WarningIcon color="currentcolor" />}>
<Message notice={notice} />
<Message notice={notice} providerName={providerName} />
</Notice>
);
}
+21 -7
View File
@@ -59,19 +59,27 @@ export default function createMiddleware(providerName: string) {
},
async (err, user, result: AuthenticationResult) => {
if (err) {
const oauthError =
err instanceof InternalOAuthError ? err.oauthError : undefined;
const providerUnavailable = oauthError?.statusCode >= 500;
// TokenError / AuthorizationError surface input problems reported by
// the upstream OAuth provider (expired or already-redeemed codes,
// access_denied, etc). They are not server bugs, so log at warn
// level and skip the error reporter.
if (err instanceof TokenError || err instanceof AuthorizationError) {
// access_denied, etc) and 5xx responses are provider outages. They
// are not server bugs, so log at warn level and skip the error reporter.
if (
err instanceof TokenError ||
err instanceof AuthorizationError ||
providerUnavailable
) {
Logger.warn(`OAuth error during authentication: ${err.message}`, {
code: err.code,
statusCode: oauthError?.statusCode,
});
} else if (oauthError instanceof Error) {
Logger.error("Error during authentication", oauthError);
} else {
Logger.error(
"Error during authentication",
err instanceof InternalOAuthError ? err.oauthError : err
);
Logger.error("Error during authentication", err, { oauthError });
}
if (err.id) {
@@ -111,6 +119,12 @@ export default function createMiddleware(providerName: string) {
);
}
if (providerUnavailable) {
return ctx.redirect(
`/?notice=provider-unavailable&provider=${encodeURIComponent(providerName)}`
);
}
if (env.isDevelopment) {
throw err;
}
@@ -1196,6 +1196,7 @@
"We could not read the user info supplied by your identity provider.": "We could not read the user info supplied by your identity provider.",
"Your account uses email sign-in. Please sign in with email to continue.": "Your account uses email sign-in. Please sign in with email to continue.",
"An email sign-in link was recently sent. Please check your inbox or try again in a few minutes.": "An email sign-in link was recently sent. Please check your inbox or try again in a few minutes.",
"{{ providerName }} returned an error. This is a temporary problem with {{ providerName }}, please try again in a few minutes.": "{{ providerName }} returned an error. This is a temporary problem with {{ providerName }}, please try again in a few minutes.",
"Authentication failed – we were unable to sign you in at this time. Please try again.": "Authentication failed – we were unable to sign you in at this time. Please try again.",
"Authentication failed – you do not have permission to access this workspace.": "Authentication failed – you do not have permission to access this workspace.",
"Sorry, it looks like that sign-in link is no longer valid. Please try requesting another.": "Sorry, it looks like that sign-in link is no longer valid. Please try requesting another.",