Updating user property not saved. User not authenticated? Yes they are.
In our production app, users are authenticated and signed up through Facebook. A facebookId and authData are present for each user. When updating a user property for any user, it fails (does not crash). Am I missing something here? Seems pretty basic.
If I call one of the signUps() I get: 2016-07-02 09:40:04.100 Corpsboard[16906:1604602] [Error]: Cannot sign up a user that has already signed up. (Code: 202, Version: 1.13.0)
Steps to reproduce
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
- Authenticate user via Facebook
- Attempt to update a given user property
iOS:
if userProfile != nil && !usersOwnProfile() {
if let viewCount = userProfile!.profileViews {
let newCount = NSNumber(int: viewCount.intValue + 1)
userProfile?.profileViews = newCount
} else {
userProfile?.profileViews = NSNumber(int: 1)
}
userProfile?.saveInBackgroundWithBlock({ (success: Bool, err: NSError?) in
print(success)
print(err)
})
}
Expected Results
The new information is saved to the user class.
Actual Outcome
The new information is not saved. The app does not crash. View log below.
Environment Setup
- Server
- parse-server version: 2.2.15
- Operating System: iOS 9
- Hardware: iPhone 6
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
- Database
- MongoDB version: 3.0.12
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
2016-07-02 09:40:04.362 Corpsboard[16906:1604602] [Error]: Caught "NSInternalInconsistencyException" with reason "User cannot be saved unless they have been authenticated via logIn or signUp":
(
0 CoreFoundation 0x00000001108c5d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000011002cdeb objc_exception_throw + 48
2 CoreFoundation 0x00000001108c5cbd +[NSException raise:format:] + 205
3 Parse 0x000000010d1813a2 -[PFUser(Private) _checkSaveParametersWithCurrentUser:] + 754
4 Parse 0x000000010d0f60df __31-[PFObject(Private) saveAsync:]_block_invoke_2.584 + 79
5 Bolts 0x000000010c0e0da0 __62-[BFTask continueWithExecutor:successBlock:cancellationToken:]_block_invoke + 160
6 Bolts 0x000000010c0e0120 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 112
7 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
8 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
9 Bolts 0x000000010c0dffbf -[BFTask continueWithExecutor:block:cancellationToken:] + 863
10 Bolts 0x000000010c0e0c86 -[BFTask continueWithExecutor:successBlock:cancellationToken:] + 310
11 Bolts 0x000000010c0e0eb4 -[BFTask continueWithSuccessBlock:] + 132
12 Parse 0x000000010d0f5ed7 __31-[PFObject(Private) saveAsync:]_block_invoke.581 + 839
13 Bolts 0x000000010c0e0120 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 112
14 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
15 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
16 Bolts 0x000000010c0e0822 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke.143 + 50
17 Bolts 0x000000010c0dfa3d -[BFTask runContinuations] + 765
18 Bolts 0x000000010c0df00c -[BFTask trySetResult:] + 252
19 Bolts 0x000000010c0e1979 -[BFTaskCompletionSource setResult:] + 89
20 Bolts 0x000000010c0e05bb __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 491
21 Bolts 0x000000010c0e0120 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 112
22 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
23 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
24 Bolts 0x000000010c0e0822 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke.143 + 50
25 Bolts 0x000000010c0dfa3d -[BFTask runContinuations] + 765
26 Bolts 0x000000010c0df00c -[BFTask trySetResult:] + 252
27 Bolts 0x000000010c0e1979 -[BFTaskCompletionSource setResult:] + 89
28 Bolts 0x000000010c0e05bb __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 491
29 Bolts 0x000000010c0e024e __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 414
30 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
31 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
32 Bolts 0x000000010c0e0822 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke.143 + 50
33 Bolts 0x000000010c0dfa3d -[BFTask runContinuations] + 765
34 Bolts 0x000000010c0df00c -[BFTask trySetResult:] + 252
35 Bolts 0x000000010c0e1979 -[BFTaskCompletionSource setResult:] + 89
36 Bolts 0x000000010c0e05bb __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 491
37 Bolts 0x000000010c0e0120 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 112
38 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
39 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
40 Bolts 0x000000010c0e0822 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke.143 + 50
41 Bolts 0x000000010c0dfa3d -[BFTask runContinuations] + 765
42 Bolts 0x000000010c0df00c -[BFTask trySetResult:] + 252
43 Bolts 0x000000010c0e1979 -[BFTaskCompletionSource setResult:] + 89
44 Bolts 0x000000010c0e05bb __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 491
45 Bolts 0x000000010c0e0120 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 112
46 Bolts 0x000000010c0db0ae __29+[BFExecutor defaultExecutor]_block_invoke_2 + 190
47 Bolts 0x000000010c0dba5e -[BFExecutor execute:] + 94
48 Bolts 0x000000010c0e0822 __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke.143 + 50
49 Bolts 0x000000010c0dfa3d -[BFTask runContinuations] + 765
50 Bolts 0x000000010c0df00c -[BFTask trySetResult:] + 252
51 Bolts 0x000000010c0e1979 -[BFTaskCompletionSource setResult:] + 89
52 Bolts 0x000000010c0e05bb __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 + 491
53 Bolts 0x000000010c0e024e __55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke + 414
54 libdispatch.dylib 0x000000011183f3eb _dispatch_client_callout + 8
55 libdispatch.dylib 0x0000000111823b74 _dispatch_barrier_sync_f_slow + 1542
56 Parse 0x000000010d1762a4 PFThreadsafetySafeDispatchSync + 148
57 Parse 0x000000010d16ecc3 __33-[PFSQLiteDatabase initWithPath:]_block_invoke_2 + 35
58 libdispatch.dylib 0x000000011181ed9d _dispatch_call_block_and_release + 12
59 libdispatch.dylib 0x000000011183f3eb _dispatch_client_callout + 8
60 libdispatch.dylib 0x0000000111827b2f _dispatch_root_queue_drain + 1829
61 libdispatch.dylib 0x0000000111827405 _dispatch_worker_thread3 + 111
62 libsystem_pthread.dylib 0x0000000111b7c4de _pthread_wqthread + 1129
63 libsystem_pthread.dylib 0x0000000111b7a341 start_wqthread + 13
).
Additionally, I attempted to do this from cloudCode but it also does not persist:
// Increment user profile view count
Parse.Cloud.define("incrementUserProfileViews", function(request, response) {
Parse.Cloud.useMasterKey();
var user = new Parse.User();
var query = new Parse.Query(Parse.User);
query.equalTo("objectId", request.params.userObjectId);
query.first({
success: function(object) {
object.increment("profileViews", 1);
object.save();
console.log("Incremented profile count")
response.success();
},
error: function(error) {
console.error("Got an error " + error.code + " : " + error.message);
response.error();
}
});
});
In my experience whenever dealing with Parse User server side (after migration) you have to use master key. According to the parse compatibility guide Parse.Cloud.UseMasterKey is no longer supported. Below is how I use master key on parse server.
In your query
query.first({
useMasterKey: true,
success: function(..){
},
error: function(..){
}
})
and your save response you should use
object.save(null, { useMasterKey: true });
@JustinDMoore does @TheRyanHickman's suggestion help? Do you call signup again on the client or save ?
@JustinDMoore can you also provide the logs when running with VERBOSE=1 ?
Closing due to lack of activity, please update to latest parse-server version and reopen if the issue persist.
Don't forget to include your current:
- node version
- npm version
- parse-server version
- any relevant logs (VERBOSE=1 will enable verbose logging)