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

PFDateFormatter dateFromString method Error #830

Closed
griffinmacias opened this issue Feb 22, 2016 · 15 comments
Closed

PFDateFormatter dateFromString method Error #830

griffinmacias opened this issue Feb 22, 2016 · 15 comments

Comments

@griffinmacias
Copy link

When I was using Parse pod 1.10.0, I noticed that method dateFromString was commented out and was just returning [NSDate new]. When I updated my Parse podfile to 1.12.0, that method was uncommented out. Now when I log in as a PFUser, kill the app, and open the App I get a crash. The crash error is that a NSDictionary instance is being sent to the method dateFromString. Commenting out dateFromString on pod 1.12.0 resolves the crash.

@nlutsenko
Copy link
Contributor

The change was in place to mitigate an bug in JavaScript SDK actually, that was encoding dates incorrectly, specifically createdAt and updatedAt.

If you can provide more info on your deployment - that would help tremendously in analyzing on where this issue is coming from.

@parse-github-bot
Copy link

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:

@griffinmacias
Copy link
Author

Sure thing, this is what I am facing from the crash

2016-02-23 09:52:44.006 With[14720:3762531] -[__NSCFDictionary UTF8String]: unrecognized selector sent to instance 0x1577e3310
(lldb) bt 
* thread #7: tid = 0x396963, 0x00000001807bff48 libobjc.A.dylib`objc_exception_throw, queue = 'com.parse.dateFormatter', stop reason = breakpoint 1.1
    frame #0: 0x00000001807bff48 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x000000018115861c CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 212
    frame #2: 0x00000001811555b8 CoreFoundation`___forwarding___ + 872
    frame #3: 0x000000018105968c CoreFoundation`_CF_forwarding_prep_0 + 92
  * frame #4: 0x00000001003426c4 With`__34-[PFDateFormatter dateFromString:]_block_invoke(.block_descriptor=0x000000016e19d908) + 60 at PFDateFormatter.m:96
    frame #5: 0x0000000100b5dbb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #6: 0x0000000100b69764 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 164
    frame #7: 0x0000000100342590 With`-[PFDateFormatter dateFromString:](self=0x00000001577ef5c0, _cmd="dateFromString:", string=2 key/value pairs) + 272 at PFDateFormatter.m:95
    frame #8: 0x0000000100386f08 With`-[PFObject(self=0x00000001577989d0, _cmd="mergeFromRESTDictionary:withDecoder:", object=11 key/value pairs, decoder=0x00000001577f1710) mergeFromRESTDictionary:withDecoder:] + 368 at PFObject.m:940
    frame #9: 0x000000010041e998 With`-[PFUser(self=0x00000001577989d0, _cmd="mergeFromRESTDictionary:withDecoder:", object=11 key/value pairs, decoder=0x00000001577f1710) mergeFromRESTDictionary:withDecoder:] + 844 at PFUser.m:643
    frame #10: 0x00000001003bc970 With`__51-[PFOfflineStore fetchObjectLocallyAsync:database:]_block_invoke166(.block_descriptor=0x00000001577e3590, task=0x00000001577f24f0) + 156 at PFOfflineStore.m:269
    frame #11: 0x00000001001f24ac With`__62-[BFTask continueWithExecutor:successBlock:cancellationToken:]_block_invoke(.block_descriptor=<unavailable>, task=0x00000001577f24f0) + 172 at BFTask.m:410
    frame #12: 0x00000001001f177c With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 124 at BFTask.m:336
    frame #13: 0x00000001001ed680 With`__29+[BFExecutor defaultExecutor]_block_invoke_2(.block_descriptor=0x00000001004c2830, block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 168 at BFExecutor.m:63
    frame #14: 0x00000001001ee0bc With`-[BFExecutor execute:](self=0x00000001577e21c0, _cmd="execute:", block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 108 at BFExecutor.m:129
    frame #15: 0x00000001001f16a4 With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke(.block_descriptor=0x00000001577ec190) + 228 at BFTask.m:328
    frame #16: 0x00000001001f1500 With`-[BFTask continueWithExecutor:block:cancellationToken:](self=0x00000001577f24f0, _cmd="continueWithExecutor:block:cancellationToken:", executor=0x00000001577e21c0, block=(With`__62-[BFTask continueWithExecutor:successBlock:cancellationToken:]_block_invoke at BFTask.m:406), cancellationToken=0x0000000000000000) + 608 at BFTask.m:379
    frame #17: 0x00000001001f23a0 With`-[BFTask continueWithExecutor:successBlock:cancellationToken:](self=0x00000001577f24f0, _cmd="continueWithExecutor:successBlock:cancellationToken:", executor=0x00000001577e21c0, block=(With`__51-[PFOfflineStore fetchObjectLocallyAsync:database:]_block_invoke166 at PFOfflineStore.m:267), cancellationToken=0x0000000000000000) + 332 at BFTask.m:406
    frame #18: 0x00000001001f25d4 With`-[BFTask continueWithSuccessBlock:](self=0x00000001577f24f0, _cmd="continueWithSuccessBlock:", block=(With`__51-[PFOfflineStore fetchObjectLocallyAsync:database:]_block_invoke166 at PFOfflineStore.m:267)) + 132 at BFTask.m:416
    frame #19: 0x00000001003bc43c With`__51-[PFOfflineStore fetchObjectLocallyAsync:database:]_block_invoke132(.block_descriptor=<unavailable>, task=0x00000001577dcc10) + 840 at PFOfflineStore.m:267
    frame #20: 0x00000001001f24ac With`__62-[BFTask continueWithExecutor:successBlock:cancellationToken:]_block_invoke(.block_descriptor=<unavailable>, task=0x00000001577dcc10) + 172 at BFTask.m:410
    frame #21: 0x00000001001f177c With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 124 at BFTask.m:336
    frame #22: 0x00000001001ed680 With`__29+[BFExecutor defaultExecutor]_block_invoke_2(.block_descriptor=0x00000001004c2830, block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 168 at BFExecutor.m:63
    frame #23: 0x00000001001ee0bc With`-[BFExecutor execute:](self=0x00000001577e21c0, _cmd="execute:", block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 108 at BFExecutor.m:129
    frame #24: 0x00000001001f16a4 With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke(.block_descriptor=0x00000001577ee560) + 228 at BFTask.m:328
    frame #25: 0x00000001001f10d4 With`-[BFTask runContinuations](self=0x00000001577dcc10, _cmd="runContinuations") + 568 at BFTask.m:308
    frame #26: 0x00000001001f06ac With`-[BFTask trySetResult:](self=0x00000001577dcc10, _cmd="trySetResult:", result=@"{\"__complete\":true,\"isDeletingEventually\":0,\"__operations\":[{\"__updatedAt\":{\"__type\":\"Date\",\"iso\":\"2016-02-23T14:46:13.375Z\"},\"__uuid\":\"CA92B327-7482-45B1-B7DB-2DB59EDD17C7\"}],\"className\":\"_User\",\"image\":{\"__type\":\"File\",\"url\":\"http:\\/\\/files.parsetfss.com\\/ec167631-a211-458b-97b2-13c0af4bbfde\\/tfss-2200a941-325e-43c7-870c-cd5c6842bcc8-image.jpg\",\"name\":\"tfss-2200a941-325e-43c7-870c-cd5c6842bcc8-image.jpg\"},\"username\":\"nBYEqEKADcf47V8cRVK2XL0sF\",\"last\":\"Macias\",\"objectId\":\"DS2uFuBSOY\",\"updatedAt\":{\"__type\":\"Date\",\"iso\":\"2016-02-23T14:46:13.370Z\"},\"first\":\"Mason\",\"createdAt\":\"2016-02-22T22:29:51.762Z\"}") + 248 at BFTask.m:223
    frame #27: 0x00000001001f30d4 With`-[BFTaskCompletionSource setResult:](self=0x00000001577ef730, _cmd="setResult:", result=@"{\"__complete\":true,\"isDeletingEventually\":0,\"__operations\":[{\"__updatedAt\":{\"__type\":\"Date\",\"iso\":\"2016-02-23T14:46:13.375Z\"},\"__uuid\":\"CA92B327-7482-45B1-B7DB-2DB59EDD17C7\"}],\"className\":\"_User\",\"image\":{\"__type\":\"File\",\"url\":\"http:\\/\\/files.parsetfss.com\\/ec167631-a211-458b-97b2-13c0af4bbfde\\/tfss-2200a941-325e-43c7-870c-cd5c6842bcc8-image.jpg\",\"name\":\"tfss-2200a941-325e-43c7-870c-cd5c6842bcc8-image.jpg\"},\"username\":\"nBYEqEKADcf47V8cRVK2XL0sF\",\"last\":\"Macias\",\"objectId\":\"DS2uFuBSOY\",\"updatedAt\":{\"__type\":\"Date\",\"iso\":\"2016-02-23T14:46:13.370Z\"},\"first\":\"Mason\",\"createdAt\":\"2016-02-22T22:29:51.762Z\"}") + 108 at BFTaskCompletionSource.m:50
    frame #28: 0x00000001001f19ec With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 748 at BFTask.m:366
    frame #29: 0x00000001001ed680 With`__29+[BFExecutor defaultExecutor]_block_invoke_2(.block_descriptor=0x00000001004c2830, block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 168 at BFExecutor.m:63
    frame #30: 0x00000001001ee0bc With`-[BFExecutor execute:](self=0x00000001577e21c0, _cmd="execute:", block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 108 at BFExecutor.m:129
    frame #31: 0x00000001001f16a4 With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke(.block_descriptor=0x00000001577ef6b0) + 228 at BFTask.m:328
    frame #32: 0x00000001001f10d4 With`-[BFTask runContinuations](self=0x00000001577e7450, _cmd="runContinuations") + 568 at BFTask.m:308
    frame #33: 0x00000001001f06ac With`-[BFTask trySetResult:](self=0x00000001577e7450, _cmd="trySetResult:", result=0x0000000000000000) + 248 at BFTask.m:223
    frame #34: 0x00000001001f30d4 With`-[BFTaskCompletionSource setResult:](self=0x00000001577cc2f0, _cmd="setResult:", result=0x0000000000000000) + 108 at BFTaskCompletionSource.m:50
    frame #35: 0x00000001001f1c24 With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_3(.block_descriptor=0x00000001577d32a0, task=0x00000001577e5920) + 528 at BFTask.m:352
    frame #36: 0x00000001001f18b8 With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2(.block_descriptor=<unavailable>) + 440 at BFTask.m:360
    frame #37: 0x0000000100b5dbb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #38: 0x0000000100b69764 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 164
    frame #39: 0x000000010040c1ac With`PFThreadsafetySafeDispatchSync(queue=0x0000000157665800, block=(With`__55-[BFTask continueWithExecutor:block:cancellationToken:]_block_invoke_2 at BFTask.m:328)) + 168 at PFThreadsafety.m:31
    frame #40: 0x00000001004046ec With`__33-[PFSQLiteDatabase initWithPath:]_block_invoke_2(.block_descriptor=<unavailable>) + 40 at PFSQLiteDatabase.m:78
    frame #41: 0x0000000100b5dbf0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #42: 0x0000000100b5dbb0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #43: 0x0000000100b6ce10 libdispatch.dylib`_dispatch_root_queue_drain + 2344
    frame #44: 0x0000000100b6c4d8 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #45: 0x0000000180db9470 libsystem_pthread.dylib`_pthread_wqthread + 1092

And when I po the string I get this

{
    "__type" = Date;
    iso = "2016-02-23T14:46:13.370Z";
}

@griffinmacias
Copy link
Author

If you need more info, let me know :)

@nlutsenko
Copy link
Contributor

The only question that I would have here - where do you get the data from?
We expect explicitly that updatedAt and createdAt on any Parse Object come as string RFC-formatted dates, and not typed date objects, so this is a backend issue - but we can fix it, just need to know where in the entire system this is.

@griffinmacias
Copy link
Author

It's coming from the PFUser's updatedAt.

@nlutsenko
Copy link
Contributor

Parse.com or Self-hosted Parse Server?

@griffinmacias
Copy link
Author

parse.com

@nlutsenko
Copy link
Contributor

Another one, sorry it's a little bit too many, but I am trying to isolate the issue.
Do you have a beforeSave/afterSave hooks by any time and if you do - what is the version of JS SDK that you are using?

@griffinmacias
Copy link
Author

All good, ask away! We do not use any beforeSave/afterSave hooks. The version of the JS SDK we are using is 1.4.2.

@griffinmacias
Copy link
Author

Updating it right now to 1.6.14. Gonna see if that helps it.

@griffinmacias
Copy link
Author

Updated to 1.6.14, still crashing.

@nlutsenko
Copy link
Contributor

Sounds pretty sad, there was a bug in JS SDK before 1.6.7 that encoded the createdAt/updatedAt fields on Parse Object in a wrong way. Whilst we can bring back the old way of doing things (safety check) - not doing so ensures that there is no bug in other place.

So, here is the most important question - what triggered the wrong save of the object in the first place.

@griffinmacias
Copy link
Author

Thanks for your help on this but the problem was occurring on our end. I had read issue #414 awhile back. Checked our system for any occurrences. I overlooked one where someone had been trying to change the updatedAt field and save the object.

@nlutsenko
Copy link
Contributor

Glad you found it. Let me know if you need any help.

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

No branches or pull requests

4 participants