Skip to content

Show human-readable error messages for known OAuth provider errors#5769

Open
carmenlau wants to merge 5 commits into
authgear:mainfrom
carmenlau:dev-3649-settings-provider-errors
Open

Show human-readable error messages for known OAuth provider errors#5769
carmenlau wants to merge 5 commits into
authgear:mainfrom
carmenlau:dev-3649-settings-provider-errors

Conversation

@carmenlau

@carmenlau carmenlau commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

ref DEV-3649

Screenshot 2026-06-11 at 11 23 54

@carmenlau carmenlau requested a review from tung2744 June 11, 2026 10:27
@carmenlau carmenlau force-pushed the dev-3649-settings-provider-errors branch from 8c8154d to d44d901 Compare June 11, 2026 22:11
Comment on lines +291 to +309
{{ $oauth_error_code := .Error.info.error }}
{{ $oauth_provider_type := .Error.info.provider_type }}
{{ if eq $oauth_error_code "access_denied" }}
<span>{{ include "v2.error.oauth-access-denied" nil }}</span>
{{ else if eq $oauth_error_code "temporarily_unavailable" }}
<span>{{ include "v2.error.oauth-temporarily-unavailable" nil }}</span>
{{ else if eq $oauth_error_code "server_error" }}
<span>{{ include "v2.error.oauth-server-error" nil }}</span>
{{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40000") }}
<span>{{ include "v2.error.oauth-iamsmart-cancelled" nil }}</span>
{{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40001") }}
<span>{{ include "v2.error.oauth-iamsmart-rejected" nil }}</span>
{{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40002") }}
<span>{{ include "v2.error.oauth-iamsmart-failed" nil }}</span>
{{ else if and (eq $oauth_provider_type "iamsmart") (eq $oauth_error_code "D40003") }}
<span>{{ include "v2.error.oauth-iamsmart-timeout" nil }}</span>
{{ else }}
<span>{{ include "v2.error.oauth-error" (dict "error" $oauth_error_code "error_description" .Error.info.error_description) }}</span>
{{ end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of handling provider specific error code here, do you think we can have a error translation in the oauthrelyingparty code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the translation and copywriting should be owned by the Auth UI layer. How about if I introduce an Error Category concept in oauthrelyingparty? And providers map their proprietary error codes to a set of defined categories, and the Auth UI template handles each category without any provider-specific logic.

Let me update the code to reflect that.

@carmenlau carmenlau changed the title Show human-readable error messages for known OAuth provider errors [WIP] Show human-readable error messages for known OAuth provider errors Jun 17, 2026
@carmenlau carmenlau force-pushed the dev-3649-settings-provider-errors branch from 62f99ef to 971a9b8 Compare June 17, 2026 11:49
carmenlau and others added 4 commits June 18, 2026 09:03
Add provider_type to OAuthError details so the template can gate
iamsmart-specific error codes. Map known RFC 6749 codes (access_denied,
temporarily_unavailable, server_error) and iamsmart D-codes (D40000–D40003)
to user-friendly messages; unknown codes fall back to the raw error string.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce ErrorCategory type and constants in oauthrelyingparty.
Providers set Category on ErrorResponse when constructing it, so
authgear-server reads the category directly without a separate interface.
The Auth UI template handles known categories and RFC 6749 codes to
display human-readable error messages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@carmenlau carmenlau force-pushed the dev-3649-settings-provider-errors branch from 971a9b8 to c04a6db Compare June 18, 2026 08:08
@carmenlau carmenlau changed the title [WIP] Show human-readable error messages for known OAuth provider errors Show human-readable error messages for known OAuth provider errors Jun 18, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@carmenlau carmenlau force-pushed the dev-3649-settings-provider-errors branch from c04a6db to b1edd0c Compare June 18, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants