It seems like the issue in #2686 (closed) is caused by an Activity somehow having a
nil AP ID. No clue how that could happen in the first place, but the piece of code in question just deletes the Activity from cache. If it has no ID, there's nothing to delete, so it can be skipped.
As to why this would happen in the first place... that's another issue. But I think this is better handling of the failure case.