react-native-keychain icon indicating copy to clipboard operation
react-native-keychain copied to clipboard

attempt to insert nil object from objects[3]' was thrown while invoking setGenericPasswordForOptions on target RNKeychainManager with param

Open chrisbarry opened this issue 3 years ago • 6 comments

Hi,

Can anyone point me in the right direction to resolve this?

iOS 14.4

Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]' was thrown while invoking setGenericPasswordForOptions on target RNKeychainManager with params ( { authenticationPrompt = { cancel = Cancel; title = "Authenticate to retrieve secret"; }; }, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjViNjA1OGY3NiJ9.eyJhdWQiOiJkYzBhZWNmZi0wZjIwLTQxMDItYTY5NS1kYWZlNGJhNTQ0NDgiLCJleHAiOjE2MTY5NjczMTQsImlhdCI6MTYxNjk2MzcxNCwiaXNzIjoiYWNtZS5jb20iLCJzdWIiOiI2YTJjMmI4ZS0zNjMyLTQ2NmYtYjk2NC03ZTA0ZWQ0MmNmNzMiLCJqdGkiOiJjOWE1OGNjNS1mMGQxLTRkOGMtOTY3MS01N2FjYTg1NzdiNTEiLCJhdXRoZW50aWNhdGlvblR5cGUiOiJQQVNTV09SRCIsImVtYWlsIjoiY0BjLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhcHBsaWNhdGlvbklkIjoiZGMwYWVjZmYtMGYyMC00MTAyLWE2OTUtZGFmZTRiYTU0NDQ4Iiwicm9sZXMiOltdfQ.p_MH0nFstUyfSzst9P8AbaFzzlaMQ84Urh6JZrBwSws", "", 652, 653 ) callstack: ( 0 CoreFoundation 0x00007fff20421af6 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48 2 CoreFoundation 0x00007fff2049e77f _CFThrowFormattedException + 194 3 CoreFoundation 0x00007fff204a9ec4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.5 + 0 4 CoreFoundation 0x00007fff2048ccb7 -[_NSPlaceholderDictionary initWithObjects:forKeys:count:] + 235 5 CoreFoundation 0x00007fff20420773 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49 6 WhosThat 0x0000000106465c5e -[RNKeychainManager setGenericPasswordForOptions:withUsername:withPassword:resolver:rejecter:] + 430 7 CoreFoundation 0x00007fff204282fc invoking + 140 8 CoreFoundation 0x00007fff204257b6 -[NSInvocation invoke] + 303 9 CoreFoundation 0x00007fff20425a47 -[NSInvocation invokeWithTarget:] + 70 10 WhosThat 0x000000010657c754 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2660 11 WhosThat 0x00000001065808fe _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 814 12 WhosThat 0x00000001065803c6 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 134 13 WhosThat 0x000000010658032c ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28 14 libdispatch.dylib 0x00007fff2010532f _dispatch_call_block_and_release + 12 15 libdispatch.dylib 0x00007fff20106508 _dispatch_client_callout + 8 16 libdispatch.dylib 0x00007fff2010c3f9 _dispatch_lane_serial_drain + 715 17 libdispatch.dylib 0x00007fff2010cf74 _dispatch_lane_invoke + 403 18 libdispatch.dylib 0x00007fff20117577 _dispatch_workloop_worker_thread + 782 19 libsystem_pthread.dylib 0x00007fff61163a3d _pthread_wqthread + 290 20 libsystem_pthread.dylib 0x00007fff61162b77 start_wqthread + 15 )

RCTFatal facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) _dispatch_call_block_and_release _dispatch_client_callout _dispatch_lane_serial_drain _dispatch_lane_invoke _dispatch_workloop_worker_thread _pthread_wqthread start_wqthread

chrisbarry avatar Mar 28 '21 20:03 chrisbarry

@chrisbarry Any luck solving this?

bosunolanrewaju avatar Apr 24 '21 04:04 bosunolanrewaju

@bosunolanrewaju No! Still got to try to work out what to do, have inherited an app from someone, this is quite a blocker... maybe have to rip some things out and work back up...

chrisbarry avatar Apr 28 '21 17:04 chrisbarry

@chrisbarry Looks like I found a fix for our issue.

See this here from https://github.com/oblador/react-native-keychain/blob/master/RNKeychainManager/RNKeychainManager.m#L354-L359:

 NSDictionary *attributes = attributes = @{
    (__bridge NSString *)kSecClass: (__bridge id)(kSecClassGenericPassword),
    (__bridge NSString *)kSecAttrService: service,
    (__bridge NSString *)kSecAttrAccount: username,
    (__bridge NSString *)kSecValueData: [password dataUsingEncoding:NSUTF8StringEncoding]
  };

The error says it is attempting to pass nil at index[3], which means the password being passed is null. Ensure that the password is not null. In our case, the value was null. Setting it to an empty string fixed it for us.

It is also mentioned in the readme file below the Usage section here that the values are limited to strings only. https://github.com/oblador/react-native-keychain#usage

HTH.

bosunolanrewaju avatar May 01 '21 11:05 bosunolanrewaju

Hi @chrisbarry I have the same problem. v. 7.0.0 very basic setup, iOs, RN 0.64

fcandi avatar May 03 '21 08:05 fcandi

@chrisbarry for me the problem resolves after adding capabilities in Xcode, see here:

https://github.com/oblador/react-native-keychain#enable-keychain-sharing-entitlement-for-ios-10

fcandi avatar May 03 '21 08:05 fcandi

In my case the issues was that I was trying to store on object Make sure you only pass strings

first-dev avatar May 19 '24 22:05 first-dev