Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancy in error handling between iOS and Android for Amplify Auth #3922

Open
BigVeila opened this issue Nov 25, 2024 · 5 comments
Open
Labels
auth Issues related to the Auth category feature-parity feature-request Request a new feature

Comments

@BigVeila
Copy link

Is your feature request related to a problem? Please describe.

I’ve noticed a significant discrepancy in how errors are handled and reported between iOS and Android for Amplify Auth. On iOS, errors are very simplified, using an enum like AuthError.invalidState with a general message. However, on Android, the same error provides much more detailed information, including the exception name like SignInException and additional context.

This inconsistency makes it challenging to maintain parity between platforms and handle errors effectively across both. For example, when trying to sign in while a user is already signed in:
• On iOS, the error is simply invalidState with a generic message. (About case Sign In Already, return only RecoverySuggestionn and ErrorDescription, Error is nil)
• On Android, the error includes the exception name SignInException, making it clearer and easier to debug.

Are there plans to align error reporting between iOS and Android so developers can have a consistent experience across platforms? It would be helpful if iOS errors could also include more detailed information, similar to Android.

Describe the solution you'd like

I would like to receive more detailed errors similar to those on Android.

Describe alternatives you've considered

No idea

Is the feature request related to any of the existing Amplify categories?

Auth

Additional context

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Nov 25, 2024
@vincetran vincetran added auth Issues related to the Auth category feature-request Request a new feature feature-parity labels Nov 25, 2024
Copy link
Contributor

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

@vincetran
Copy link
Member

vincetran commented Nov 25, 2024

Hi @BigVeila, thanks for bringing this up. Currently there are no explicit plans for bringing the error handling into parity but we'll log this feature request in our backlog.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Nov 25, 2024
@vincetran vincetran removed the pending-triage Issue is pending triage label Nov 25, 2024
@harsh62
Copy link
Member

harsh62 commented Nov 25, 2024

@BigVeila
Is this an issue with only About case Sign In Already?
Does Android also throw an invalid state and the underlying exception is SignInException?

@BigVeila
Copy link
Author

BigVeila commented Nov 27, 2024

@harsh62

Is this an issue with only About case Sign In Already?

  • No, I see that the Android side has many exceptions, but all of them are derived from 8 basic exceptions, which are also present on iOS

Does Android also throw an invalid state and the underlying exception is SignInException?

  • Yes

On iOS only have enum AuthError

`public enum AuthError {

/// Caused by issue in the way auth category is configured
case configuration(ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused by some error in the underlying service. Check the associated error for more details.
case service(ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused by an unknown reason
case unknown(ErrorDescription, Error? = nil)

/// Caused when one of the input field is invalid
case validation(Field, ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused when the current session is not authorized to perform an operation
case notAuthorized(ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused when an operation is not valid with the current state of Auth category
case invalidState(ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused when an operation needs the user to be in signedIn state
case signedOut(ErrorDescription, RecoverySuggestion, Error? = nil)

/// Caused when a session is expired and needs the user to be re-authenticated
case sessionExpired(ErrorDescription, RecoverySuggestion, Error? = nil)

}`

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Nov 27, 2024
@tylerjroach
Copy link
Member

Hi @BigVeila,

Inconsistent error handling is something we would like to work on for a future Amplify major version. It is something that we can't easily reconcile on our v2, as it would require breaking changes, but we have held internal meetings on the topic. The current behavioral differences are partially due to language differences (ex: inheritance).

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth category feature-parity feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

4 participants