Split of some known error cases from `fxa-client-other-error`

NoExistingAuthFlow can happen when users manually navigate through the
oauth flow URLs. Just count the errors in Glean rather than report them
to Sentry.  Use a separate label for the errors, and reserve `fxa_other`
for unexpected errors.

Handle OriginMismatch the same, which can happen when trying to pair two
firefox instances that are configured to use different servers.

BackoffError was similar, but I kept the sentry reporting for this one,
since it seems useful to see the reason for backoff errors.  Going
through the current list of backoff errors lead me to open #5918
This commit is contained in:
Ben Dean-Kawamura 2023-11-14 09:28:46 -05:00 коммит произвёл bendk
Родитель 56bcdac661
Коммит acbb1bef48
4 изменённых файлов: 33 добавлений и 12 удалений

Просмотреть файл

@ -41,6 +41,8 @@ fxa_client:
labels: labels:
- network - network
- authentication - authentication
- no_existing_auth_flow
- origin_mismatch
- fxa_other - fxa_other
- unexpected - unexpected
bugs: bugs:

Просмотреть файл

@ -513,6 +513,12 @@ class FxaClient(inner: FirefoxAccount, persistCallback: PersistCallback?) : Auto
} catch (e: FxaException.Authentication) { } catch (e: FxaException.Authentication) {
FxaClientMetrics.errorCount["authentication"].add() FxaClientMetrics.errorCount["authentication"].add()
throw e throw e
} catch (e: FxaException.NoExistingAuthFlow) {
FxaClientMetrics.errorCount["no_existing_auth_flow"].add()
throw e
} catch (e: FxaException.OriginMismatch) {
FxaClientMetrics.errorCount["origin_mismatch"].add()
throw e
} catch (e: FxaException) { } catch (e: FxaException) {
FxaClientMetrics.errorCount["fxa_other"].add() FxaClientMetrics.errorCount["fxa_other"].add()
throw e throw e

Просмотреть файл

@ -38,6 +38,12 @@ pub enum FxaError {
/// **Note:** This error is currently only thrown in the Swift language bindings. /// **Note:** This error is currently only thrown in the Swift language bindings.
#[error("the requested authentication flow was not active")] #[error("the requested authentication flow was not active")]
WrongAuthFlow, WrongAuthFlow,
/// Origin mismatch when handling a pairing flow
///
/// The most likely cause of this is that a user tried to pair together two firefox instances
/// that are configured to use different servers.
#[error("Origin mismatch")]
OriginMismatch,
/// A scoped key was missing in the server response when requesting the OLD_SYNC scope. /// A scoped key was missing in the server response when requesting the OLD_SYNC scope.
#[error("The sync scoped key was missing")] #[error("The sync scoped key was missing")]
SyncScopedKeyMissingInServerResponse, SyncScopedKeyMissingInServerResponse,
@ -194,17 +200,21 @@ impl GetErrorHandling for Error {
| Error::NoRefreshToken | Error::NoRefreshToken
| Error::NoScopedKey(_) | Error::NoScopedKey(_)
| Error::NoCachedToken(_) => { | Error::NoCachedToken(_) => {
ErrorHandling::convert(crate::FxaError::Authentication).log_warning() ErrorHandling::convert(FxaError::Authentication).log_warning()
}
Error::RequestError(_) => {
ErrorHandling::convert(crate::FxaError::Network).log_warning()
} }
Error::RequestError(_) => ErrorHandling::convert(FxaError::Network).log_warning(),
Error::SyncScopedKeyMissingInServerResponse => { Error::SyncScopedKeyMissingInServerResponse => {
ErrorHandling::convert(crate::FxaError::SyncScopedKeyMissingInServerResponse) ErrorHandling::convert(FxaError::SyncScopedKeyMissingInServerResponse)
.report_error("fxa-client-scoped-key-missing") .report_error("fxa-client-scoped-key-missing")
} }
_ => ErrorHandling::convert(crate::FxaError::Other) Error::UnknownOAuthState => {
.report_error("fxa-client-other-error"), ErrorHandling::convert(FxaError::NoExistingAuthFlow).log_warning()
}
Error::BackoffError(_) => {
ErrorHandling::convert(FxaError::Other).report_error("fxa-client-backoff")
}
Error::OriginMismatch => ErrorHandling::convert(FxaError::OriginMismatch),
_ => ErrorHandling::convert(FxaError::Other).report_error("fxa-client-other-error"),
} }
} }
} }

Просмотреть файл

@ -59,11 +59,8 @@ enum FxaError {
// The application may retry at a later time once connectivity is restored. // The application may retry at a later time once connectivity is restored.
"Network", "Network",
// Thrown if the application attempts to complete an OAuth flow when no OAuth flow // Thrown if the application attempts to complete an OAuth flow when no OAuth flow has been initiated for that state.
// has been initiated. This may indicate a user who navigated directly to the OAuth // This may indicate a user who navigated directly to the OAuth `redirect_uri` for the application.
// `redirect_uri` for the application.
//
// **Note:** This error is currently only thrown in the Swift language bindings.
"NoExistingAuthFlow", "NoExistingAuthFlow",
// Thrown if the application attempts to complete an OAuth flow, but the state // Thrown if the application attempts to complete an OAuth flow, but the state
@ -75,6 +72,12 @@ enum FxaError {
// **Note:** This error is currently only thrown in the Swift language bindings. // **Note:** This error is currently only thrown in the Swift language bindings.
"WrongAuthFlow", "WrongAuthFlow",
// Origin mismatch when handling a pairing flow
//
// The most likely cause of this is that a user tried to pair together two firefox instances
// that are configured to use different servers.
"OriginMismatch",
// The sync scoped key was missing in the server response // The sync scoped key was missing in the server response
"SyncScopedKeyMissingInServerResponse", "SyncScopedKeyMissingInServerResponse",