Parse-sdk-ios-osx: PFKeychainStore failed to set object for key 'currentUser', with error: -34018

Created on 20 Oct 2015  ·  124Comments  ·  Source: parse-community/Parse-SDK-iOS-OSX

User is authenticated with facebook.

sometimes when i try to do a fb request:

let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/friends", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in

it spams:
PFKeychainStore failed to set object for key 'currentUser', with error: -34018
in the console.

Needs Investigation Needs More Info

Most helpful comment

@mooshee

Hi, I was getting this error earlier "PFKeychainStore failed to set object for key 'currentUser'".

After browsing on stack overflow, I found out that "Apple changed the way of working with keychain in iOS 10.", henceforth you have to turn on "keychain sharing"

http://stackoverflow.com/a/38799196/2472466

I hope that helps ...

All 124 comments

Hey @a1exb1, this sounds super weird.
The error is coming down from our keychain storage for authData/sessionToken for currentUser, since that information should be private.

Any chance you can get us more context on when it happens and/or more data about the state of currentUser when the problem happens?

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

  • Documentation: https://www.parse.com/docs
  • Google Groups: https://groups.google.com/forum/#!forum/parse-developers
  • Stack Overflow: http://stackoverflow.com/tags/parse.com

I also get this issue periodically and it's hard to tell what causes it. It just seems like it can randomly occur. I'm finding debugging the Parse SDK to be indeed very difficult because you can't trace back to the calling context due to all the BFTasks in between, etc.

I'm using a pretty recent SDK, since I only started working with Parse 1-2 weeks ago.

The same for me. I have tried it in two apps, one with FB authentication and one without.
Both fire this error log. You have to hard close the app and rerun it again, so you can hope to get logged in.

This bug is killing me, because one time appears, and one time it doesn't. And I am using the latest SDK.
@nlutsenko We need your magic touch :).

yes, seriously. This has basically torpedoed my client’s project.

Can we get any insight into why it happens??

On Friday 30 October 2015 at 09:55, Perjan Duro wrote:

The same for me. I have tried it in two apps, one with FB authentication and one without.
Both fire this error log. You have to hard close the app and rerun it again, so you can hope to get logged in.
This bug is killing me, because one time appears, and one time it doesn't. And I am using the latest SDK.
@nlutsenko (https://github.com/nlutsenko) We need your magic touch :).


Reply to this email directly or view it on GitHub (https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/437#issuecomment-152463261).

Just right now I got this error, when I tried to edit a property in a PFUser logged from a FB account.

For me it just continues to carry on working, but I’m unsure as to what’s happened. I don’t get invalid session token errors or anything like that.

On Friday 30 October 2015 at 10:48, Perjan Duro wrote:

Just right now I got this error, when I tried to edit a property in a PFUser logged from a FB account.
[Error]: Caught "NSInternalInconsistencyException" with reason "User cannot be saved unless they have been authenticated via logIn or signUp":


Reply to this email directly or view it on GitHub (https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/437#issuecomment-152475342).

I updated to Parse v 1.9.1 . So far so good...

I have seen this again, but I'm wondering if it's because it's an async API and I had set a breakpoint. Anyhow, the problem is much less running 1.9.1 !!

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

Hey guys, I've looked further into this error, and it looks to be a bug in the Security framework itself.
It's been discussed and acknowledged by Apple here - https://forums.developer.apple.com/thread/4743#14441

Is anyone getting any other error except of -34018?

I just got this error. On Parse 1.9.1 and Facebook 4.7.0.

I honestly don't know how to reproduce. Maybe a hint is that when I have crappy network connection..

[Error]: PFKeychainStore failed to get object for key 'currentUser', with error: -34018

I am having the same error when logging in with Twitter, not every time. I am using Parse 1.9.1 and iOS 9.1

This keeps happening with an app I am developing as well. It is preventing us from moving forward.

@brennanMKE How does this prevent you guys from proceeding?
Is there a change in behavior or say failing requests? Or simply an error logged to the console?

@nlutsenko We are trying to get push notifications to work and I am trying to set values on the User instance so that Cloud Code can determine when a push will be triggered. Since I cannot set values on the User it prevents push notifications from being processed.

Either I get this error or UserCannotBeAlteredWithoutSessionError. I have the AppDelegate run PFUser.enableAutomaticUser() in application:didFinishLaunchingWithOptions: which should ensure that an anonymous user is created. Yet sometimes it is nil after it shows the error with the keychain. Then once I do get a user it is not possible to save the user because of the session.

Gotcha. @brennanMKE, any chance you can add a repro project that has this issue reproducible at least semi-consistently?

@nlutsenko

I dug into it and found something which does not make sense to me. This is an iOS app built with Swift. I have been using PFUser.currentUser() after Parse is initialized and PFUser.enableAutomaticUser() is called. I am expecting that PFUser.currentUser() always returns a valid user but sometimes it returns a nil value.

So I called PFSession.getCurrentSessionInBackgroundWithBlock to get a session and checked session?.objectForKey("user") which does return a user but the objectId on that user does not match the user from PFUser.currentUser().

I expect that currentUser and currentSession would be synced up when enableAutomaticUser is used. What I am going to do next is a create a class in Swift called ParseSupport which will use blocks to return the Session and User objects and never use PFUser.currentUser() and instead always go through the Session. That approach may prevent these errors and allow for saving a user reliably.

Are my expectations accurate or am I not understanding how currentUser and currentSession should work?

That is super strange at this point... enableAutomaticUser() has a guarantee indeed that PFUser.currentUser() won't be nil, and it will create an empty unsaved user for you otherwise (won't save it automatically to Parse, but will create in-memory local one for sure).
session?["user"] should be set to PFUser.currentUser(), otherwise there is something funky going on with the sessionToken, meaning that the PFUser.currentUser().sessionToken belongs to a different user than the currentUser().

I am extremely curious to see the repro for this and fix/investigate further.

I now get invalid session token when I try to save changes to the user. I am going delete and reinstall the app again. It's strange.

After deleting and installing the app again it immediately shows the -34018 error.

PFKeychainStore failed to get object for key 'currentUser', with error: -34018

[Error]: invalid session token (Code: 209, Version: 1.9.1)

It is like the keychain is persisting data across app installs and I do not know a good way to do that on my device without doing a full reset like I can do with the iOS Simulator.

@brennanMKE Can you please attach a sample repro project? I will be more than glad to investigate, but simply can't repro it running on the device.

There is nothing unusual in this app. In the AppDelegate in application:didFinishLaunchingWithOptions: Parse is configured like I have done many times. Then the code immediately tries to get the current user and save it to ensure that any other calls work later, such as saving the user with the PFInstallation object. I do not know if creating another project would recreate this problem. What I'd like to do is reset the keychain for the app but unfortunately deleting the app does not also remove keychain items related to the app so they seem to be there when the app is installed from Xcode later.

// Parse.enableLocalDatastore()
Parse.setApplicationId("appId", clientKey:"clientKey")
PFUser.enableAutomaticUser()

I have enabled the local database though not objects were pinned. I have since commented out that line.

@nlutsenko What I am doing now is preparing some code in Swift which will log out the current values in the keychain so I can see what is in there. And once I can see the keychain items I will delete them. Maybe that will fix the problem.

I do not think it is the code. It is the persisting data in the keychain which is not being purged between installs.

I have been facing this issue for last 2 weeks very consistently. It is easily reproducible as well. I just force a webview based authentication:

  [PFFacebookUtils setFacebookLoginBehavior:FBSessionLoginBehaviorForcingWebView];
  [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
      if (!user) {
           return;
      } else if (user.isNew) {
            FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"name, picture, email, gender, location, about, bio"}];
            [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
              NSLog(@"Error %@",error);
            }];
         }        
    }];

I first get the following error from above block:

    body =     {
         error =         {
              code = 2500;
              "fbtrace_id" = BNWEwNELi9T;
              message = "An active access token must be used to query information about the current user.";
              type = OAuthException;
          };
     };
   code = 400;

Then, it throws:
PFKeychainStore failed to get object for key 'currentUser', with error: -34018

I am using ParseFacebookUtils 1.9.1 and Parse 1.9.1, running on iOS 9.1

That error above ^^ looks like is coming from FBSDK not Parse.
I wonder if there is something weird going on in their field...

@nlutsenko If it helps, [FBSDKAccessToken currentAccessToken] is nil on a new user signup in the logInWithPermissions: block. However, in my subsequent login attempts using the above method, there is no error. So, I was guessing it could be because current user is not linked with the FBAccessToken. I can provide more info if you want.

@kshdeo I would love to see the full repro project that I can repro this with, as any of the local testing that I am doing doesn't surface this issue in any way. If it's super private - you can send it to nlutsenko(at)fb.com

Thanks @nlutsenko ! I will send you a stripped down version of the project removing the private pieces.

Hey @nlutsenko , did you receive my email with the app code attached?

@kshdeo, yes, didn't have a chance to dive deep into this. Sorry for the delay, will try my best to get to it fast.

@kshdeo actually I did not, for some reason it didn't attach to the email that you've sent.
@brennanMKE I can't seem to be able to open your project either :( Can you re-send it again?

@kshdeo Found the issue with your project - let me fix it real quick and send it back to you.
tl;dr Usage of ParseFacebookUtils for FBSDK v3 with FBSDK v4 :)

Just started using Parse again, and I'm experiencing this "error" as well. It logs in the console in Xcode, but surprisingly doesn't seem to have any negative effect as I continue to use the app. It also seems to happen sporadically, and does not always happen when I signup as a new user.

I'm going to take another look at it in the morning and see if I can figure out what exactly is causing this to log to the console. Here's the exact error:

[Error]: PFKeychainStore failed to get object for key 'currentUser', with error: -34018

Here's a list of some of the related Pods and their versions that I'm using:

  • FBSDKCoreKit (4.8.0):

    • Bolts (~> 1.1)

    • FBSDKCoreKit/arc (= 4.8.0)

    • FBSDKCoreKit/no-arc (= 4.8.0)

    • FBSDKCoreKit/arc (4.8.0):

    • Bolts (~> 1.1)

    • FBSDKCoreKit/no-arc (4.8.0):

    • Bolts (~> 1.1)

    • FBSDKCoreKit/arc

    • FBSDKLoginKit (4.8.0):

    • FBSDKCoreKit

    • FBSDKShareKit (4.8.0):

    • FBSDKCoreKit

  • Parse (1.9.1):

    • Bolts/Tasks (>= 1.4.0)

    • ParseFacebookUtilsV4 (1.9.1):

    • Bolts/Tasks (>= 1.5)

    • FBSDKCoreKit (~> 4.8)

    • FBSDKLoginKit (~> 4.8)

    • Parse (~> 1.9)

Thanks @nlutsenko. The link you sent gives an error saying that I do not have access so I could not test.

I've done a bit of research on that:
http://stackoverflow.com/questions/29740952/osstatus-error-code-34018

I've been able to work around it by force signing the binary as an extra build script:

The following snippet with get the proper signing identity and force sign the binary.
https://devforums.apple.com/message/917498#917498

echo "codesign --verify --force --sign \"$CODE_SIGN_IDENTITY\" \"$CODESIGNING_FOLDER_PATH\""
IDENTITIES=`security find-identity -v -s "Code Signing" | grep "iPhone Developer" | awk '{ print $2 }'`


for SHA in $IDENTITIES; do
    codesign --verify --force --sign $SHA "$CODESIGNING_FOLDER_PATH"
    if [ $? -eq 0 ]; then
        echo "Matching identity found: $SHA"
        exit 0
    fi
done;

exit 1

I talked with another iOS dev last night who has also had trouble with the iOS keychain. He confirmed that he saw what I have been seeing. Even when I delete an app and reinstall it the data in the keychain for the app is still there. I believe since it is still in place it causes this problem with the user and session. I expect that with an anonymous user the current user and session will always be valid, especially when the app is deleted and reinstalled again.

Currently with the Parse SDK there is no way to reset the user and session data in the keychain. I'd like to have some way of clearing it out to eliminate this problem.

@brennanMKE PFUser.logOut() will completely reset the keychain, meaning it will remove anything from the keychain that was persisted there for this user.

@nlutsenko Thanks, when I get that error code I will try that. That might clear it up.

I still get this error a lot even after calling PFUser.logOut() and restarting the app.

PFKeychainStore failed to get object for key 'currentUser', with error: -34018

Behavior is sporadic. I now have this code in the AppDelegate which runs when the app is launched. It should not fail with an error but if it does the code will log out the user. The goal is to at least clear out the keychain if there are problems and once the app is restarted the current user and session will be in a good state.

if let user = PFUser.currentUser() {
    user.setObject(Tracker.sharedInstance().getUserIdentifier(), forKey: "localUserIdentifier")
    user.saveInBackgroundWithBlock({ (success, error) -> Void in
        if let error = error {
            Tracker.sharedInstance().trackParseError(error)
            // reset the user by clearing out the keychain items
            PFUser.logOut()
        }
        else if success {
            let installation = PFInstallation.currentInstallation()
            installation.setObject(user, forKey: "user")
            installation.saveInBackground()
        }
    })
}

@brennanMKE I agree. I get this sporadically too. For me, I'm checking to see if the user is logged in during app start and it prints out the error but PFUser.currentUser() proceeds as normal. It would be nice if it failed so I could do something about it.

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

+1

Using Parse (1.11.0)
Using ParseFacebookUtilsV4 (1.9.1)
Using FBSDKCoreKit (4.8.0)
Using FBSDKLoginKit (4.8.0)
Using FBSDKShareKit (4.8.0)

Well, I'm still getting the error using the Parse 1.11.0 client...

PFKeychainStore failed to get object for key 'currentUser', with error: -34018

When I get a chance, I will try and see if I can dig deeper into this and report anything I find.

I too am getting this error, I created a stackoverflow question...and I was pointed to this thread - however it seems like the problem has not been resolved here. I am using the latest Parse SDK and still receiving the error with both setObject and setValue.

My stack question is here: http://stackoverflow.com/questions/34381870/parse-error-when-updating-user-info-with-currentuser?noredirect=1#comment56515769_34381870

I just tried again and didn't have an issue - I'll report back if it happens again.

Now I am getting the error, but it is not affecting the storing of data on parse. As long as that is the case I'm just going to ignore it :)

-> PFKeychainStore failed to set object for key 'currentUser', with error: -34018
-> 1.11.0

When tried to login via Twitter it goes too long and than this error appeared.
It causes server side errors because "request.user == null" in that case

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

@nlutsenko Would be some actions due to this issue?

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

@nlutsenko Once again. Would be some actions with this issue?

@batkov, I am going to dive deep into this today closer, but as before - any good repro would be very welcome.

@nlutsenko I've been trying to see if I can find a good way to reproduce this error, unfortunately, it appears to be fairly random so it leads be to think that it maybe concurrency related. I don't know how others are getting this error, but for me it happens quite often during development, especially when starting and stopping the app in Xcode. I don't know if that actually prevents the Parse SDK from saving the account info into the Keychain when abruptly stopping an app. Unfortunately, I haven't had a chance to take a look into the SDK source myself...

Does this help at all? I put a breakpoint where the error message occurs and I printed a backtrace from lldb.

(lldb) bt
* thread #2: tid = 0x2d7142, 0x0000000100b42b38 Parse`-[PFKeychainStore _dataForKey:](self=0x000000013edc8f90, _cmd="_dataForKey:", key=@"currentUser") + 368 at PFKeychainStore.m:112, queue = 'com.parse.keychain.io.bluecloud.LogLittle.com.parse.sdk', stop reason = breakpoint 6.1
  * frame #0: 0x0000000100b42b38 Parse`-[PFKeychainStore _dataForKey:](self=0x000000013edc8f90, _cmd="_dataForKey:", key=@"currentUser") + 368 at PFKeychainStore.m:112
    frame #1: 0x0000000100b4281c Parse`__32-[PFKeychainStore objectForKey:]_block_invoke(.block_descriptor=0x000000016e086a68) + 56 at PFKeychainStore.m:80
    frame #2: 0x0000000102695bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #3: 0x00000001026a1b08 libdispatch.dylib`_dispatch_sync_f_invoke + 136
    frame #4: 0x0000000100b42574 Parse`-[PFKeychainStore objectForKey:](self=0x000000013edc8f90, _cmd="objectForKey:", key=@"currentUser") + 280 at PFKeychainStore.m:79
    frame #5: 0x0000000100b42994 Parse`-[PFKeychainStore objectForKeyedSubscript:](self=0x000000013edc8f90, _cmd="objectForKeyedSubscript:", key=@"currentUser") + 72 at PFKeychainStore.m:98
    frame #6: 0x0000000100b102f0 Parse`__80-[PFCurrentUserController _loadSensitiveUserDataAsync:fromKeychainItemWithName:]_block_invoke(.block_descriptor=0x000000013ed74db0) + 132 at PFCurrentUserController.m:278
    frame #7: 0x000000010050cf4c Bolts`__37+[BFTask taskFromExecutor:withBlock:]_block_invoke(.block_descriptor=<unavailable>, task=0x000000013ed74e40) + 80 at BFTask.m:204
    frame #8: 0x000000010050e244 Bolts`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 124 at BFTask.m:336
    frame #9: 0x0000000102695bf0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #10: 0x0000000102695bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #11: 0x00000001026a4e10 libdispatch.dylib`_dispatch_root_queue_drain + 2344
    frame #12: 0x00000001026a44d8 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #13: 0x00000001808e1470 libsystem_pthread.dylib`_pthread_wqthread + 1092

There's also a very large stack trace on thread 2 (in my case) in the Debug Navigator. I'll see if there's a better way to extract the data for you instead of providing screenshots.

@zenkimoto try using thread bt all, that should give output from all threads.

@richardjrossiii Thank you!! I learned something new about LLDB!

The application stopped this time on thread 7. While I can't find a good way to reproduce this, hopefully this will give you some clue?

Here's the backtrace for all threads.

  thread #1: tid = 0x315547, 0x00000001808014f8 libsystem_kernel.dylib`semaphore_wait_trap + 8, queue = 'com.apple.main-thread'
    frame #0: 0x00000001808014f8 libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x0000000102687b94 libdispatch.dylib`_dispatch_semaphore_wait_slow + 244
    frame #2: 0x0000000100a96ae4 Parse`-[BFTask(self=0x0000000127eb6350, _cmd="waitForResult:withMainThreadWarning:", error=0x0000000000000000, warningEnabled=NO) waitForResult:withMainThreadWarning:] + 228 at BFTask+Private.m:120
    frame #3: 0x0000000100ba0a64 Parse`+[PFUser currentUser](self=PFUser, _cmd="currentUser") + 108 at PFUser.m:781

    ... Single Threaded Call Stack of my Application to [PFUser currentUser] method ...

    frame #14: 0x000000010004d198 LogLittle`@objc LogLittle.AppDelegate.application (LogLittle.AppDelegate)(__ObjC.UIApplication, didFinishLaunchingWithOptions : Swift.Optional<Swift.Dictionary<__ObjC.NSObject, Swift.AnyObject>>) -> Swift.Bool + 208 at AppDelegate.swift:0
    frame #15: 0x00000001859e1704 UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
    frame #16: 0x0000000185c10130 UIKit`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904
    frame #17: 0x0000000185c144b8 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1672
    frame #18: 0x0000000185c115c0 UIKit`-[UIApplication workspaceDidEndTransaction:] + 168
    frame #19: 0x000000018222f790 FrontBoardServices`-[FBSSerialQueue _performNext] + 184
    frame #20: 0x000000018222fb10 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
    frame #21: 0x0000000180c30efc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #22: 0x0000000180c30990 CoreFoundation`__CFRunLoopDoSources0 + 540
    frame #23: 0x0000000180c2e690 CoreFoundation`__CFRunLoopRun + 724
    frame #24: 0x0000000180b5d680 CoreFoundation`CFRunLoopRunSpecific + 384
    frame #25: 0x00000001859da580 UIKit`-[UIApplication _run] + 460
    frame #26: 0x00000001859d4d90 UIKit`UIApplicationMain + 204
    frame #27: 0x000000010004ec00 LogLittle`main + 136 at AppDelegate.swift:16
    frame #28: 0x00000001806fe8b8 libdyld.dylib`start + 4

  thread #2: tid = 0x315578, 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #0: 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001808e1530 libsystem_pthread.dylib`_pthread_wqthread + 1284

  thread #3: tid = 0x315579, 0x000000018081d4fc libsystem_kernel.dylib`kevent_qos + 8, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x000000018081d4fc libsystem_kernel.dylib`kevent_qos + 8
    frame #1: 0x000000010268a270 libdispatch.dylib`_dispatch_mgr_invoke + 232
    frame #2: 0x0000000102677e2c libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #4: tid = 0x31557b, 0x00000001808014f8 libsystem_kernel.dylib`semaphore_wait_trap + 8, queue = 'com.parse.preload'
    frame #0: 0x00000001808014f8 libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x0000000102687b94 libdispatch.dylib`_dispatch_semaphore_wait_slow + 244
    frame #2: 0x0000000100a96ae4 Parse`-[BFTask(self=0x0000000127eaed50, _cmd="waitForResult:withMainThreadWarning:", error=0x0000000000000000, warningEnabled=NO) waitForResult:withMainThreadWarning:] + 228 at BFTask+Private.m:120
    frame #3: 0x0000000100ba0a64 Parse`+[PFUser currentUser](self=PFUser, _cmd="currentUser") + 108 at PFUser.m:781
    frame #4: 0x0000000100a9cba4 Parse`__47-[ParseManager preloadDiskObjectsToMemoryAsync]_block_invoke(.block_descriptor=<unavailable>) + 76 at ParseManager.m:440
    frame #5: 0x00000001004acf4c Bolts`__37+[BFTask taskFromExecutor:withBlock:]_block_invoke(.block_descriptor=<unavailable>, task=0x0000000127ead270) + 80 at BFTask.m:204
    frame #6: 0x00000001004ae244 Bolts`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 124 at BFTask.m:336
    frame #7: 0x0000000102675bf0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #8: 0x0000000102675bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #9: 0x00000001026826c8 libdispatch.dylib`_dispatch_queue_drain + 1036
    frame #10: 0x00000001026798a0 libdispatch.dylib`_dispatch_queue_invoke + 464
    frame #11: 0x0000000102675bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #12: 0x0000000102684e10 libdispatch.dylib`_dispatch_root_queue_drain + 2344
    frame #13: 0x00000001026844d8 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #14: 0x00000001808e1470 libsystem_pthread.dylib`_pthread_wqthread + 1092

  thread #5: tid = 0x31557c, 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #0: 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001808e1530 libsystem_pthread.dylib`_pthread_wqthread + 1284

* thread #7: tid = 0x315581, 0x0000000100af2b38 Parse`-[PFKeychainStore _dataForKey:](self=0x0000000127eaf1d0, _cmd="_dataForKey:", key=@"currentUser") + 368 at PFKeychainStore.m:112, queue = 'com.parse.keychain.io.bluecloud.LogLittle.com.parse.sdk', stop reason = breakpoint 3.1
  * frame #0: 0x0000000100af2b38 Parse`-[PFKeychainStore _dataForKey:](self=0x0000000127eaf1d0, _cmd="_dataForKey:", key=@"currentUser") + 368 at PFKeychainStore.m:112
    frame #1: 0x0000000100af281c Parse`__32-[PFKeychainStore objectForKey:]_block_invoke(.block_descriptor=0x000000016e246a68) + 56 at PFKeychainStore.m:80
    frame #2: 0x0000000102675bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #3: 0x0000000102681b08 libdispatch.dylib`_dispatch_sync_f_invoke + 136
    frame #4: 0x0000000100af2574 Parse`-[PFKeychainStore objectForKey:](self=0x0000000127eaf1d0, _cmd="objectForKey:", key=@"currentUser") + 280 at PFKeychainStore.m:79
    frame #5: 0x0000000100af2994 Parse`-[PFKeychainStore objectForKeyedSubscript:](self=0x0000000127eaf1d0, _cmd="objectForKeyedSubscript:", key=@"currentUser") + 72 at PFKeychainStore.m:98
    frame #6: 0x0000000100ac02f0 Parse`__80-[PFCurrentUserController _loadSensitiveUserDataAsync:fromKeychainItemWithName:]_block_invoke(.block_descriptor=0x0000000127ebb2b0) + 132 at PFCurrentUserController.m:278
    frame #7: 0x00000001004acf4c Bolts`__37+[BFTask taskFromExecutor:withBlock:]_block_invoke(.block_descriptor=<unavailable>, task=0x0000000127e96c80) + 80 at BFTask.m:204
    frame #8: 0x00000001004ae244 Bolts`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 124 at BFTask.m:336
    frame #9: 0x0000000102675bf0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #10: 0x0000000102675bb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #11: 0x0000000102684e10 libdispatch.dylib`_dispatch_root_queue_drain + 2344
    frame #12: 0x00000001026844d8 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #13: 0x00000001808e1470 libsystem_pthread.dylib`_pthread_wqthread + 1092

  thread #8: tid = 0x315582, 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #0: 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001808e1530 libsystem_pthread.dylib`_pthread_wqthread + 1284

  thread #9: tid = 0x315583, 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #0: 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001808e1530 libsystem_pthread.dylib`_pthread_wqthread + 1284

  thread #10: tid = 0x315584, 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #0: 0x000000018081cb6c libsystem_kernel.dylib`__workq_kernreturn + 8
    frame #1: 0x00000001808e1530 libsystem_pthread.dylib`_pthread_wqthread + 1284

  thread #11: tid = 0x315589, 0x00000001808014bc libsystem_kernel.dylib`mach_msg_trap + 8, name = 'com.apple.NSURLConnectionLoader'
    frame #0: 0x00000001808014bc libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x0000000180801338 libsystem_kernel.dylib`mach_msg + 72
    frame #2: 0x0000000180c30ac0 CoreFoundation`__CFRunLoopServiceMachPort + 196
    frame #3: 0x0000000180c2e7c4 CoreFoundation`__CFRunLoopRun + 1032
    frame #4: 0x0000000180b5d680 CoreFoundation`CFRunLoopRunSpecific + 384
    frame #5: 0x00000001812cd434 CFNetwork`+[NSURLConnection(Loader) _resourceLoadLoop:] + 412
    frame #6: 0x000000018163bc40 Foundation`__NSThread__start__ + 1000
    frame #7: 0x00000001808e3b28 libsystem_pthread.dylib`_pthread_body + 156
    frame #8: 0x00000001808e3a8c libsystem_pthread.dylib`_pthread_start + 156

@nlutsenko
Im finding this error manifests if: I have a valid PFUser. aka calls to the save properties to Parse eventually or in the background work fine. But if i then background the app, and then bring to foreground again I start getting the KeyChain issues.

This reminds me of problems I had with this library https://github.com/kishikawakatsumi/UICKeyChainStore/issues/106

Anyways maybe that info helps.... it manifests after backgrounding and then bringing the app to foreground... then attempting a PFUser.save()

and then subsequent builds of the app or runs of the app display the PFKeychainStore failed to set object for key 'currentUser', with error: -34018
as probably something is now corrupted.

until I wipe the build and build run fresh.

I'm getting the same symptoms as what @mitchellporter mentioned above.

Also getting this issue, not using Facebook login or anything like that, just logging the user in on the server and using becomeInBackground:. Previously got this issue previously using loginWithUsername:password:

Issue persists when deleting and reinstalling the app.

I've done a bit of poking around and can see that the issue occurs for me on line 72 of PFUserController - specifically when the app has logged in succesfully, and then tries to serialize the user object to disk so it can be accessed later via currentUser:

    return [[controller saveCurrentObjectAsync:user] continueWithBlock:^id(BFTask *task) {
        return user;
    }];

Hopefully this helps you guys out.

I too have been getting this issue sporadically. Currently haven't found a way to reproduce it. I'm not using Facebook login or automatic users though. I only use the loginWithUsername:password: and logout methods.

I have been getting this issue few months. I don't use neither FaceBook login, nor Twitter. Only loginWithUsername and password.

It hasn't bothered me until it stopped saving data in background to my PFUser.currentUser()

+1

+1

Getting the same error with parse-server running locally.
PFKeychainStore failed to get object for key 'currentUser', with error: -34018

It also seems to affect Cloud Code, because I get _undefined_ inside my cloud function when doing
console.log(request.user)

This error has been around for quite long. They just announced they are turning Parse down, so do not expect this to be fixed. In my tests I have realized that this only happens when debugging, so in release it won't happen

On 31 Jan 2016, at 01:53, Makar [email protected] wrote:

Getting the same error with parse-server running locally.
PFKeychainStore failed to get object for key 'currentUser', with error: -34018


Reply to this email directly or view it on GitHub.

They just announced they are turning Parse down, so do not expect this to be fixed.

All of the code is open sourced, nothing stopping the community from fixing this.

getting the same bug

+1
I have had this bug when logout and login several times.But it occurs randomly.

I'm using regular login username/password.

I had the same issue today, especially after running the app on my device, but using my Parse "dev" app, instead of my "prod" app. I specifically ran the app by after changing the ParseAppID/ParseClientID to my dev ones (without deleting the app first). Since then it corrupted my session token.

I tried deleting the app, logging out > logging back in, logging out > guest login > log back in, etc... Nothing worked. Logging in using other users was fine, just that user got corrupted.

  1. So I ended up going to Parse Dashboard > Session > locate the sessions that point to that corrupted user object > Delete them.
  2. Then I logged back in, which showed the same PFKeychainStore errors, then if you close the app, and run again, it will show invalid session token.

3. SOLUTION - The only way that "resolved" the issue was to:
a. Keep the user logged in on the device.
b. On Parse Dashboard > Session > located that last session token that was created/updated that points to the corrupted user.
c. Delete it
d. Run the app again, which will show an invalid session token (which is expected, as you deleted the entry for it).
e. Login again using username/password
f. Shouldn't see the error anymore. Consecutive app launches should behave fine.

Hope that helps!

posted this as a separate issue but I think it belongs here.

Getting this error when trying to save relations to a user after updating my app from 1.6.2 -> 1.12.0 in anticipation of migration. However after updating my iOS app "Tipped" which uses PFRelation a lot..... is super buggy, and weirdly the scroll performance on my collection views have dropped.

Here is the error response when trying to save a relation:

error response/ console log in xcode:
2016-03-01 15:24:29.415 [Error]: PFKeychainStore failed to get object for key 'currentUser', with error: -34018
2016-03-01 15:24:29.421 [Error]: PFKeychainStore failed to set object for key 'currentUser', with error: -34018
like obejct saved for Optional("bubbles")

Code:
let like = Like(photo: photo, user: user)

like.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
if error == nil {
let likeCreatedAtRelation = user.relationForKey("like_createdat")
likeCreatedAtRelation.addObject(like)
user.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
self.photo.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
self.transitionInProgress = false
print("like obejct saved for (user.firstName)")
})
})
} else {
print("error.userInfo: (error!.userInfo)")
}
})

Is the PFRelation broken???: bad news for me since my app relies heavily on this

I have a feeling that PFKeychainStore isn't working as it should, so when I try to save a relation to a user it can't find the user I am talking about.

I really want to migrate, but parse 1.12 destroys my Tipped's user experience. What should I do? Check it out on the app store running on parse 1.6.2, everything is smooth, but with the new parse 1.12 the collection views are super jittery and weird saving a querying issues

needs your skillz @nlutsenko come save all the rookie coders who got dumped by fb.

Keychain error -34018 (errSecMissingEntitlement) is a known bug in the iOS Keychain.

The problem can be easily reproduced but Apple hasn't had success fixing it. Only solution would be to bypass it at this point.

Apple Forums Reference with repro steps: https://forums.developer.apple.com/thread/4743

This is a major issue for us as our app remains live in the background and is supposed to keep the users logged in at all times.

In our Parse app the steps to reproduce and track it on the console are the following:

  1. Log in into the app while debugging with Xcode on a device
  2. Send the app into the background
  3. Open the Xcode Debug Navigator and select the CPU & Memory view
  4. On the device open memory intensive apps (e.g. Maps with 3d flyover) and use up as much RAM as possible (ideally less than 100mb free)
  5. Open the app and the error should appear in the console while the app calls +[PFUser CurrentUser]

Apparently what triggers the issue is an access to the keychain while the keychain isn't ready (app startup or resume). A partial solution could be to delay this access by some milliseconds until the security framework has managed to properly initialise.

When this bug is triggered the only solution is to kill the app or it will be encountered at every attempt to access the keychain (both read/write).

I had the same error [Error]: PFKeychainStore failed to get object for key 'currentUser', with error: -34018 when calling Parse.setApplicationId(ApplicationId, clientKey: ClientKey) immediately before calling PFUser.currentUser(). Changing the app logic to have more time between these two instructions solved it and the error message disappeared.

UPDATE: Not getting this issue anymore. It was happening on all the times I tried to [[PFUser currentUser] setValue:VALUE forKey:KEY]. When I switched to setObject, I wasn't dealing with the issues anymore!

I'm also getting this same error anytime I try to save/edit a property on [PFUser currentUser]. I get the error on both the set & get. Sometimes it will save the property, sometimes it wont and there is no error happening from the saveInBackgroundWithBlock: so I can't catch the issue.

I think I have finally fixed this issue. I'm pretty sure this issue is being caused due to special circumstances when constantly re-running the app, creating/deleting new test users, etc.

Before I describe my fix, here are all the errors I have been receiving related to this issue:

  • PFKeychainStore failed to set object for key 'currentUser', with error: -34018
  • Parse Code=101 "object not found for update" UserInfo={code=101, temporary=0, error=object not found for update, NSLocalizedDescription=object not found for update
  • "error" : "Parse::UserCannotBeAlteredWithoutSessionError" code: 206
  • [Error]: Parse::UserCannotBeAlteredWithoutSessionError (Code: 206, Version: 1.11.0)
  • Error Domain=com.facebook.sdk.login Code=308

Also before I describe my fix, here's a quick description of my app's user setup. Your mileage may vary depending on what you are doing:

  • PFUser.enableAutomaticUser() is called in the app delegate's didFinishLaunchingWithOptions to enable auto anonymous user creation
  • There are 2 buttons on the user's profile page. One is to connect with Twitter, the other with Facebook. If the user presses these, the Facebook/Twitter connect dialogues show and the user can accept or deny.
  • When the user accepts these, the User data in Parse should have authData for both Facebook and Twitter.
  • User has successfully "logged in/signed up" with Twitter and Facebook and granted my app access.

Here is how I fixed this problem. I basically figured out how to do a full reset of all user data when you want to test this stuff. I had been deleting session and user data from the database, but I think the final key was to clear the keychain data using the logout method. Big thanks to @nlutsenko for recommending this.

So, to fix this problem I did the following:

  • Deleted testing Session in the Parse database
  • Deleted testing User in the Parse database
  • Commented out PFUser.enableAutomaticUser() in my app delegate's didFinishLaunchingWithOptions so that a new anonymous user would not be created on this run.
  • In my initial view controller's viewDidLoad, I call PFUser.logOutInBackgroundWithBlock and wait for completion.

After completing the above steps, I comment out the call to PFUser.logOutInBackgroundWithBlock and uncomment the call to PFUser.enableAutomaticUser() in my app delegate's didFinishLaunchingWithOptions

I then run the application again, and I can go through my whole anonymous user login/signup process that I listed above, and it works perfectly. No errors at all.

NEWS FROM APPLE https://forums.developer.apple.com/thread/4743

OK, here’s the latest. This is a complex problem with multiple possible causes:
Some instances of the problem are caused by incorrect app signing. You can easily distinguish this case because the problem is 100% reproducible.
Some instances of the problem are caused by a bug in how iOS supports app development (r. 23,991,853). Debugging this was complicated by the fact that another bug in the OS (r. 23,770,418) masked its effect, meaning the problem only cropped up when the device was under memory pressure.
We believe these problems were resolved in iOS 9.3.
We suspect that there may be yet more causes of this problem.
So, if you see this problem on a user device (one that hasn’t been talked to by Xcode) that’s running iOS 9.3 or later, please do file a bug report about it. Try to include the device system log in your bug report (I realise that can be tricky when dealing with customer devices; one option is to ask the customer to install Apple Configurator, which lets them view the system log). And if you do file a bug, please post your bug number, just for the record.
On behalf of Apple I’d like to thank everyone for their efforts in helping to track down this rather horrid issue.
Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"

Woo! That's great news! Should we close this then?

Yey!

Btw, I dont have that error anymore on iOs 9.3

Programming for food,
Nick Halavins
AntiChat.me

2016-04-13 20:36 GMT+03:00 Nikita Lutsenko [email protected]:

Woo! That's great news! Should we close this then?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/437#issuecomment-209558085

Perfect!
Then, since we have a final confirmation from multiple source about the fact that this is fixed in iOS 9.3 and was indeed Apple bug - I am going to close this issue.

Fingers crossed. We are still testing but it seems to be significantly improved at least.

I can confirm that in certain situations this bug is still happening. Although less frequently than before.

Parse push is not working when i will change the parse migration.
it will be show in my parse server installation table.the data will show but the push is not working. please let me know how to debug that issue.

This error is still happening for me as well. It's not a big issue when trying to query/save data from the Parse Server, but when I try to run cloud code the user property within the cloud function is reported as nil. Has anyone encountered this?

@nlutsenko I just realized that is issue is marked as closed (same as this one which seems to be very much alike: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/609) -- should we reopen these to try to find a solution to the problem as it seems to still be happening for a number of us?

I'm running iOS 10.0 and I'm still seeing this issue. More information on steps to reproduce can be found at https://github.com/ParsePlatform/parse-server/issues/2104.

Client Environment:
Xcode 8 beta 5
Swift 3.0
Parse iOS SDK 1.14.2

Server Environment: (cloned current parse-server-example and added Cloud Code function below)
parse-server 2.2.18

@mooshee

Hi, I was getting this error earlier "PFKeychainStore failed to set object for key 'currentUser'".

After browsing on stack overflow, I found out that "Apple changed the way of working with keychain in iOS 10.", henceforth you have to turn on "keychain sharing"

http://stackoverflow.com/a/38799196/2472466

I hope that helps ...

Thank you @takomborerwa. This fixed the issue with iOS 10 and Parse Server.

@mooshee Thanks man, you saved my day.

I have a problem with PFUser.current() when i try to save/upload this user.

Xcode return PFKeychainStore failed to set object for key 'currentUser', with error: -34018

Here is the post: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/1060

Help please!

Try enabling keychain sharing

Is necessary Apple developer account?

Hi?

That's highly probable.

Puf.
Nobody try this?
I need a solution..

When you enable keychain sharing in Xcode for your app target. Does it work?

Because i do not have apple developer account, Xcode return when i enable keychain sharing:
captura de pantalla 2016-10-22 a las 18 37 48

Is the entitlements file created? Can you confirm that it's still not working? You probably want to create a developper account anyway.

I kill the app and delete all user in DataBase of Parse and when i try to edit a user and change few fields i can do it, but when i try to do it again, the problem return.

Is this ?
captura de pantalla 2016-10-22 a las 18 41 13

Yes, of course i need a developer account but i want to be sure that this development will run and i will not have to change Parse for other solution like Firebase, for example.

I like Parse and i want to continue working with him.

Yes that's the entitlements file, your issue would be resolved by having a full developer account. Starting iOS 10, I believe apple enforced more strongly keychain access from dynamically linked frameworks. Without the proper Keychain Sharing entitlements, it seems that the SDK is not correctly working.

This is the content of the entitlements and the message of Xcode when i enable the keychain sharing:

captura de pantalla 2016-10-22 a las 18 45 31
captura de pantalla 2016-10-22 a las 18 46 06

Yes and that should be solved if you have a proper developer account, and a properly configured Xcode.

So i have to bet that the program will run when i will have an apple developer account?

Nobody happen this now?

It is not very professional betting by a project what don´t run now...

The only solution is apple developer account so?

Flovilmart, to you do not happens?

It's happening to everyone who is building/running Parse on iOS 10. As Flovilmart outlined, the SDK stores the users' session information in the keychain. Apple changed the rules for 3rd party data to be read/write to the keychain. You must have an Apple Developer to enable keychain sharing.

You cannot release an app without an Apple Developer account. Many features (such as Push Notifications) require an account. To insinuate Parse, or it's community, is unprofessional for this reason is to also assume Apple is unprofessional. Perhaps Firebase would suit you better.

Please, you don´t say things that i don´t say.

I am really charmed with Parse. My question is because i am doing a course about Parse and this problem don´t happen and i will want to know why, just this.

Of course i know that i can not release my app without Apple Developer account, only i will want to delay the moment of the payment for economic problems.

I don´t know why you attack me of this way but, you know.

Sorry if someone has been offended, it was not my intention.

My statement still stands: Firebase may suit you better (if you have the option in your coursework). If you must build your app for iOS 10, then you will need a developer account or deal with an invalid session between every launch. Perhaps your class has not run into this issue because they are building / running on iOS 9 or prior.

Does that answer your question?

I believe creating an Apple Developer account is FREE, you can now even test the app on the device without paying a dime. Once you're ready to release, then you'll need to pay.

Yes, @KBog is right. You can see the chart at the bottom of the linked page below which shows that with an Apple ID you can create a developer account and deploy apps to a device. And if someone were to add you to their paid team it is possible you could have access to more functionality.

And schools can enroll in the iOS Developer University Program for free which could make several useful features available.

https://developer.apple.com/support/compare-memberships/

Thanks @brennanMKE !

I tried my app in my device and it is so cool!

Regrettably to try the keychain storage i need an individual apple developer account, but for the moment i can try my app whit this.

When i will release my app, i will buy the individual apple developer account to try the keychain storage and test that my app run correctly and i can modify a PFUser.

@jose46moreno You may want to duplicate your build target for your app so you can have a few app identifiers which each have their own keychain so that as you work you can manage them separately. I found that even deleting an app does not delete the associated keychain, so after installing the app again there are still remnants. I don't think that is correct behavior for iOS, but I've seen it happen. That's a bug which is beyond what the Parse SDK can handle.

Updating a cell's nib with the method setImageForUserName like so [cell.profPic setImageForUserName:PFUser.currentUser.username]; returns a PFKeychainStore failed to set object for key 'currentUser', with error: -34018. Are there any suggestions about this particular method?

@ericgiannini Have you already followed the steps above to enable keychain sharing? If not, you are likely see this type of error across the entire app every time you try to access a remote object that is protected by the user's session.

Thanks, @mooshee! I will take the steps & update you. ;)

Hi all.

I just started receiving this error:

PFKeychainStore failed to set object for key 'currentUser', with error: -25299

but only in the simulator. I am on Xcode 10.1, and an older version of the Parse SDK. I upgraded to the current version of the Parse SDK, and no difference. We have upgraded our Parse backend. Doesn't seem like that should have an effect on the front end though.

I've started following the chain back in this thread, but haven't come across anything yet. I do have a valid developer account, and am looking at the entitlement issues now.

I'm posting because the error number is different than what seems to run though this thread, so not sure if I have something different here.

If anyone has any info, please let me know, and I'll continue backtracking through this thread.

Thanks!

@tekmick I encountered this thread that may be of interest: https://github.com/yankodimitrov/SwiftKeychain/issues/13

Sent with GitHawk

Ok, my bad. We have a couple of branches working on an upgrade of Parse for both back and front end. I was positive I was on the upgraded front end branch when I tested, but I wasn't. I am good here.

flovilmart, thanks for the pointer!

Thanks!

On Mon, Feb 4, 2019 at 3:29 PM Florent Vilmart notifications@github.com
wrote:

@tekmick https://github.com/tekmick I encountered this thread that may
be of interest: yankodimitrov/SwiftKeychain#13
https://github.com/yankodimitrov/SwiftKeychain/issues/13

Sent with GitHawk http://githawk.com


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/parse-community/Parse-SDK-iOS-OSX/issues/437#issuecomment-460455257,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AclPwvXH_Y3V-PROAKoPiQOGozjNx3bJks5vKMJcgaJpZM4GRwZ6
.

Was this page helpful?
0 / 5 - 0 ratings