wordpress-mobile / wordpress-mobile/WordPress-iOS
Discarding all local drafts from the dashboard card leads to a crash
Open
Nobody has claimed this yet.
[Pri] Low
[Type] Crash
My Site
- Dominant language
- Swift
- Stars
- 3.9k
- Forks
- 1.2k
- Avg merge
- 23h 51m
- Merged PRs (30d)
- 58
Description
Expected behavior
The app shouldn't crash.
Actual behavior
Discarding local drafts from the dashboard card crashes the app after the final draft is discarded.
Steps to reproduce the behavior
- Launch the Jetpack app.
- Switch to a site that preferably has no draft posts.
- Create a local-only draft by either:
a. Create a blog post > enter in some title and body content > kill app, OR
b. Switching to airplane mode and creating a new blog post, OR - From the Home Dashboard, scroll down and find the Drafts card.
- Tap the draft > Tap close > Discard. Continue until all drafts are discarded.
- Verify that the app crashed.
Here's the error stack trace:
CoreData: error: NSFetchedResultsController: no object at index 0 in section at index 0
2023-07-23 13:48:28.188910+0700 Jetpack[57449:15317007] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'no object at index 0 in section at index 0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011bf56330 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000010eb45274 objc_exception_throw + 56
2 CoreData 0x000000010f361aa4 -[NSFetchedResultsController indexPathForObject:] + 0
3 Jetpack 0x0000000104f554d0 $s9WordPress18PostsCardViewModelC6postAtyAA4PostC10Foundation9IndexPathVF + 360
4 Jetpack 0x0000000105d41bd0 $s9WordPress26DashboardPostsListCardCellC9tableView_14didSelectRowAtySo07UITableI0C_10Foundation9IndexPathVtF + 164
5 Jetpack 0x0000000105d41ff4 $s9WordPress26DashboardPostsListCardCellC9tableView_14didSelectRowAtySo07UITableI0C_10Foundation9IndexPathVtFTo + 136
6 UIKitCore 0x0000000142de62b8 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:isCellMultiSelect:deselectPrevious:performCustomSelectionAction:] + 1208
7 UIKitCore 0x0000000142de65c8 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 252
8 UIKitCore 0x00000001430619e8 -[_UIAfterCACommitBlock run] + 64
9 UIKitCore 0x0000000143061e14 -[_UIAfterCACommitQueue flush] + 164
10 UIKitCore 0x0000000142c1fce8 _runAfterCACommitDeferredBlocks + 492
11 UIKitCore 0x0000000142c11a6c _cleanUpAfterCAFlushAndRunDeferredBlocks + 104
12 UIKitCore 0x0000000142c3bd50 _afterCACommitHandler + 60
13 CoreFoundation 0x000000011beb8c10 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
14 CoreFoundation 0x000000011beb357c __CFRunLoopDoObservers + 512
15 CoreFoundation 0x000000011beb3a20 __CFRunLoopRun + 948
16 CoreFoundation 0x000000011beb3254 CFRunLoopRunSpecific + 584
17 GraphicsServices 0x0000000124b9fc9c GSEventRunModal + 160
18 UIKitCore 0x0000000142c12ff0 -[UIApplication _run] + 868
19 UIKitCore 0x0000000142c16f3c UIApplicationMain + 124
20 Jetpack 0x0000000105ee3410 main + 496
21 dyld 0x000000010e6e9514 start_sim + 20
22 ??? 0x000000010e5f5f28 0x0 + 4536098600
23 ??? 0x7c44000000000000 0x0 + 8954281959119388672
)
Tested on iPhone 14 Simulator, iOS 16.4, Jetpack iOS 22.8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching for PostsCardViewModel.postAt and DashboardPostsListCardCell.tableView(_:didSelectRowAt:) in the Jetpack iOS project, then reproduce the final local-draft discard flow described above. Trace how the dashboard card handles an empty draft list after the last discard. Done means discarding the final local draft no longer crashes the app.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100