firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.66k stars 1.48k forks source link

`AuthErrorCode` no longer conforms to `Error` on 11.0.0 #13430

Closed xmollv closed 3 months ago

xmollv commented 3 months ago

Description

I saw a new major version was published (11.0.0) so I tried to upgrade to it. Everything seems smooth except for AuthErrorCode. We have a few places where we checked if the error returned was of such type, and if it was, we checked the code and in a specific case the localizedDescription because the error wouldn't tells us exactly what happened. Here are the two instances where we have such behavior:

Just checking the code:

if let firebaseError = error as? AuthErrorCode, firebaseError.code == .networkError {
  // Don't logout if the error is that the network is down!
  return nil
} else {
  try? await logoutSignedInUser(userInitiated: false)
  onUnrecoverableAuthError?()
}

Checking code and localizedDescription to disambiguate the real error:

if let firebaseError = error as? AuthErrorCode, firebaseError.code == .invalidPhoneNumber {
  switch firebaseError.localizedDescription {
  case "TOO_SHORT":
    throw FirebaseError.phoneNumberTooShort
  case "TOO_LONG":
    throw FirebaseError.phoneNumberTooLong
  default:
    throw firebaseError
  }
} else {
  throw error
}

After updating to 11.0.0 this code no longer compiles, and I didn't see any breaking changes about this on the Auth part of the release notes: https://firebase.google.com/support/release-notes/ios#authentication.

Reproducing the issue

Upgrade from 10.29.0 to 11.0.0 and use AuthErrorCode anywhere in your codebase.

Firebase SDK Version

11.0.0

Xcode Version

15.4

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication

Targeted Platforms

iOS

Relevant Log Output

Screenshot 2024-07-31 at 11 10 40

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
```json { "pins" : [ { "identity" : "abseil-cpp-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/abseil-cpp-binary.git", "state" : { "revision" : "194a6706acbd25e4ef639bcaddea16e8758a3e27", "version" : "1.2024011602.0" } }, { "identity" : "analytics-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/analytics-swift", "state" : { "revision" : "33f07bd5e4d216de92a163a8edad2c3216087cd9", "version" : "1.5.5" } }, { "identity" : "app-check", "kind" : "remoteSourceControl", "location" : "https://github.com/google/app-check.git", "state" : { "revision" : "21fe1af9be463a359aaf8d96789ef73fc3760d09", "version" : "11.0.1" } }, { "identity" : "facebook-ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/facebook/facebook-ios-sdk", "state" : { "revision" : "9ed465ccd73c231144d49a9c681774577c616f34", "version" : "17.0.2" } }, { "identity" : "firebase-ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/firebase-ios-sdk.git", "state" : { "revision" : "a5c253d1b4409eb8aef4346015ba000f9935cb2d", "version" : "11.0.0" } }, { "identity" : "giphy-ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/Giphy/giphy-ios-sdk", "state" : { "revision" : "16cbb3368f77e73735abc3d9b15871d1e6c120cc", "version" : "2.2.9" } }, { "identity" : "googleappmeasurement", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleAppMeasurement.git", "state" : { "revision" : "ca30c987b732d130732fb60b071e0b655a85ada7", "version" : "11.0.0" } }, { "identity" : "googledatatransport", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleDataTransport.git", "state" : { "revision" : "617af071af9aa1d6a091d59a202910ac482128f9", "version" : "10.1.0" } }, { "identity" : "googleutilities", "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleUtilities.git", "state" : { "revision" : "66dd81c729364b0425d0c2b73e38a489f32b1717", "version" : "8.0.1" } }, { "identity" : "grpc-binary", "kind" : "remoteSourceControl", "location" : "https://github.com/google/grpc-binary.git", "state" : { "revision" : "f56d8fc3162de9a498377c7b6cea43431f4f5083", "version" : "1.65.1" } }, { "identity" : "gtm-session-fetcher", "kind" : "remoteSourceControl", "location" : "https://github.com/google/gtm-session-fetcher.git", "state" : { "revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", "version" : "3.5.0" } }, { "identity" : "instabug-sp", "kind" : "remoteSourceControl", "location" : "https://github.com/Instabug/Instabug-SP", "state" : { "revision" : "4bb06bdcc8493261b21fa80eebcb750a99753b19", "version" : "13.2.0" } }, { "identity" : "interop-ios-for-google-sdks", "kind" : "remoteSourceControl", "location" : "https://github.com/google/interop-ios-for-google-sdks.git", "state" : { "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", "version" : "100.0.0" } }, { "identity" : "ios-sdk", "kind" : "remoteSourceControl", "location" : "https://github.com/spotify/ios-sdk", "state" : { "revision" : "cc087da108cc95f3ca4aa4e64a526be688472bcb", "version" : "2.1.6" } }, { "identity" : "jsonsafeencoder-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/jsonsafeencoder-swift.git", "state" : { "revision" : "8b70dc8c01b7b041912e30e29d2b488a43f782ac", "version" : "1.0.1" } }, { "identity" : "leveldb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/leveldb.git", "state" : { "revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", "version" : "1.22.5" } }, { "identity" : "libwebp-xcode", "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/libwebp-Xcode", "state" : { "revision" : "b2b1d20a90b14d11f6ef4241da6b81c1d3f171e4", "version" : "1.3.2" } }, { "identity" : "lnextensionexecutor", "kind" : "remoteSourceControl", "location" : "https://github.com/LeoNatan/LNExtensionExecutor.git", "state" : { "revision" : "c0226dcd7d653d4c22dd16ccd72619c86b610c2d", "version" : "1.3.0" } }, { "identity" : "lottie-spm", "kind" : "remoteSourceControl", "location" : "https://github.com/airbnb/lottie-spm", "state" : { "revision" : "b842598f1295f3ffa1475b1580672d1fe5b83580", "version" : "4.5.0" } }, { "identity" : "nanopb", "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/nanopb.git", "state" : { "revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", "version" : "2.30910.0" } }, { "identity" : "phonenumberkit", "kind" : "remoteSourceControl", "location" : "https://github.com/marmelroy/PhoneNumberKit", "state" : { "revision" : "0a025521711539e3a6e0e725ac868ac84a4983e1", "version" : "3.7.11" } }, { "identity" : "promises", "kind" : "remoteSourceControl", "location" : "https://github.com/google/promises.git", "state" : { "revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", "version" : "2.4.0" } }, { "identity" : "sdwebimage", "kind" : "remoteSourceControl", "location" : "https://github.com/SDWebImage/SDWebImage", "state" : { "revision" : "86e9185ef41c4238a93ad8efe61ddeb701e80bbf", "version" : "5.19.5" } }, { "identity" : "snap-kit-spm", "kind" : "remoteSourceControl", "location" : "https://github.com/Snapchat/snap-kit-spm", "state" : { "revision" : "6c44e89e330e8b37ea3f7405d75c9a161d4f8281", "version" : "2.5.0" } }, { "identity" : "socket.io-client-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/socketio/socket.io-client-swift", "state" : { "branch" : "development", "revision" : "d069bbeefe6b31c4a711d93a2b6be063a79d1175" } }, { "identity" : "sovran-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/sovran-swift.git", "state" : { "revision" : "24867f3e4ac62027db9827112135e6531b6f4051", "version" : "1.1.2" } }, { "identity" : "starscream", "kind" : "remoteSourceControl", "location" : "https://github.com/daltoniam/Starscream", "state" : { "revision" : "ac6c0fc9da221873e01bd1a0d4818498a71eef33", "version" : "4.0.6" } }, { "identity" : "swift-protobuf", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { "revision" : "e17d61f26df0f0e06f58f6977ba05a097a720106", "version" : "1.27.1" } } ], "version" : 2 } ```
google-oss-bot commented 3 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

paulb777 commented 3 months ago

@xmollv Thanks for the report. We appreciate your quick feedback on 11.0.0!

I've proposed a fix at #13434 and will follow up with the team on getting it reviewed and merged.