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

LinkError Type mismatch #501

Closed
enlightenedpie opened this issue Aug 18, 2022 · 4 comments · Fixed by #556
Closed

LinkError Type mismatch #501

enlightenedpie opened this issue Aug 18, 2022 · 4 comments · Fixed by #556

Comments

@enlightenedpie
Copy link

The problem

I'm purposefully passing a null linkToken to the tokenConfig so I can react to any errors from initialization. However, the error object shape I'm receiving is very different from the LinkExit.error type and the Plaid Link documentation. Instead of null, I also tried passing a random string (not a valid token) and got the same error object shape.

{"code": "ECOM.PLAID.LINK0", "domain": "com.plaid.link", "message": "The operation couldn’t be completed. (com.plaid.link error 0.)", "nativeStackIOS": ["0   <AppNameRedacted>                        0x0000000100f0051c RCTJSErrorFromCodeMessageAndNSError + 116", "1   <AppNameRedacted>                       0x0000000100f00468 RCTJSErrorFromNSError + 256", "2   <AppNameRedacted>                        0x00000001013719f4 -[RNLinksdk open::] + 1124", "3   CoreFoundation                      0x00000001b1b61b24 5198FB57-5645-3B34-A49F-F32B52256CF3 + 138020", "4   CoreFoundation                      0x00000001b1b7f610 5198FB57-5645-3B34-A49F-F32B52256CF3 + 259600", "5   CoreFoundation                      0x00000001b1bb65fc 5198FB57-5645-3B34-A49F-F32B52256CF3 + 484860", "6   <AppNameRedacted>                        0x0000000100e99ac8 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1828", "7   <AppNameRedacted>                        0x0000000100e9d604 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1156", "8   <AppNameRedacted>                        0x0000000100e9cfa4 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144", "9   <AppNameRedacted>                        0x0000000100e9cf08 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28", "10  libdispatch.dylib                   0x00000001b183ee6c 355ACCF4-3917-3730-BC55-EF7003887ABE + 7788", "11  libdispatch.dylib                   0x00000001b1840a30 355ACCF4-3917-3730-BC55-EF7003887ABE + 14896", "12  libdispatch.dylib                   0x00000001b184ef48 355ACCF4-3917-3730-BC55-EF7003887ABE + 73544", "13  libdispatch.dylib                   0x00000001b184eb98 _dispatch_main_queue_callback_4CF + 44", "14  CoreFoundation                      0x00000001b1b91800 5198FB57-5645-3B34-A49F-F32B52256CF3 + 333824", "15  CoreFoundation                      0x00000001b1b4b704 5198FB57-5645-3B34-A49F-F32B52256CF3 + 46852", "16  CoreFoundation                      0x00000001b1b5ebc8 CFRunLoopRunSpecific + 600", "17  GraphicsServices                    0x00000001cdc92374 GSEventRunModal + 164", "18  UIKitCore                           0x00000001b44ce648 3ED35565-456D-33CB-B554-6C567FA81585 + 5326408", "19  UIKitCore                           0x00000001b424fd90 UIApplicationMain + 364", "20  <AppNameRedacted>                        0x000000010091d168 main + 96", "21  dyld                                0x00000001040edce4 start + 520"], "userInfo": {"message": "self.clientName is , but must be a properly formatted, non-empty string"}}

In development environments this is fine, I can just react to error.code instead of error.errorCode.... However, for non-dev environments, the typescript compiler breaks at this point because code doesn't exist on the LinkError type. For now I'm just using a ts-ignore on that line, but that can't really be a long-term solution... especially since the code I'm seeing is "ECOM.PLAID.LINK0" which is not one of LinkErrorCode. I'm only seeing this on iOS right now, not testing on Android at the moment, so i don't know if it's also happening on Android.

Am I just completely off on my expectations of this error?

Thank you in advance for your help!

Environment

Plaid Link React Native 7.0.7
ReactNative Version 0.67.3
Occurs on Android untested
Android OS Version
Android Devices/Emulators
Occurs on iOS yes
iOS Version 15.5
iOS Devices/Emulators iPhone 13 Pro Max

Steps to Reproduce

  1. Pass null (or string that is not a valid token) as 'token' in tokenConfig
  2. Inspect error object

Expected Result

I was expecting the error object to have the LinkError shape, as that is the expected type on LinkExit.error

{
    errorCode: LinkErrorCode;
    errorType: LinkErrorType;
    errorMessage: string;
    errorDisplayMessage?: string;
    displayMessage?: string;
    errorJson?: string;
}

Screenshots

N/A

Logs

N/A

Code To Reproduce Issue

const plaidExit = (linkExit: LinkExit): void => console.log(linkExit.error);

<PlaidLink
  tokenConfig={{
    token: null,
    logLevel: LinkLogLevel.DEBUG,
  }}
  onExit={plaidExit}
>
  <Button />
</PlaidLink>
@lucidprojects
Copy link

I'm having a similar error after upgrading to 10.5.0. 🍿

@dtroupe-plaid
Copy link
Collaborator

@lucidprojects - thanks for confirming this still exists. It's actually a bug in iOS LinkKit SDK

@objc public static func createWithLinkTokenConfiguration(
        _ linkTokenConfiguration: PLKLinkTokenConfiguration,
        error: NSErrorPointer
    ) -> PLKHandler? {
        let result = Plaid.create(linkTokenConfiguration.toSwift)
        switch result {
        case .success(let handler):
            return PLKHandlerShim(handler: handler)
        case .failure(let errorValue):
            error?.pointee = errorValue.toObjC
        }
        return nil
    }

where toObjC is

extension Plaid.CreateError {
    var toObjC: NSError {
        switch self {
        case .configurationError(let error):
            return NSError(
                domain: kPLKDefaultErrorDomain,
                code: error.toObjC.rawValue,
                userInfo: ["message": error.message]
            )
        }
    }
}

We should be returning a PLKLinkExit instead. I will make the update to the iOS SDK and push a fix in the next release. Hoping this will be released before 9/15 🤞

@dtroupe-plaid
Copy link
Collaborator

Resolved by #556

@dtroupe-plaid
Copy link
Collaborator

Released in V10.6.0

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 a pull request may close this issue.

3 participants