Crash During Orphaned Managed Object with Ambiguous KeyPaths #1111

Closed
blakewatters opened this Issue Dec 27, 2012 · 5 comments

Projects

None yet

2 participants

@blakewatters
Member

There is a crashing issue due to keyPath ambiguity when working with dynamic mappings and the local object deletion support. The issue goes like this:

  1. Configure a dynamic mapping for a keyPath (i.e. reviews)
  2. Add 2 entity mappings to the keyPath with relationships to other entities. (i.e. airport and amenity)
  3. Map a payload that matches one of the mappings in the dynamic mapping (i.e. the one containing the 'amenity' relationship)
  4. Get crash as 1valueForKeyPath:is evaluated against a nested keyPath for the mapping that did not match. (valueForKeyPath:` is invoked with the key path reviews.airport, which raises an exception because the mapped entities don't respect that key path).

There are two possible fixes for this:

  1. Rescue the exception and keep going. This has performance degradation because of the exception handling.
  2. Rework the logic to avoid invoking the key path that did not match. This probably means eliminating the response descriptor visitor in favor of using RKMapperOperationDelegate methods to track the mappings that are applied to the response and then visiting all of the edges from there.
@blakewatters blakewatters was assigned Dec 27, 2012
@blakewatters blakewatters added a commit that referenced this issue Dec 27, 2012
@blakewatters blakewatters Add temporary workaround for crashes related to ambiguous key paths i…
…n the deletion support. refs #1111
7745f17
@blakewatters blakewatters added a commit that referenced this issue Dec 29, 2012
@blakewatters blakewatters Rework implementation of managed object deletion and refetching to us…
…e the refreshed visitor implementation. refs #1111, #1113
6493282
@blakewatters
Member

I am not in love with the solution in place here -- it involves allowing an exception to be raised and then capturing it, but I don't see a more elegant solution at the moment. @jeffarena -- we should benchmark this in GateGuru for v3.2 -- the exception may be a performance problem.

@blakewatters
Member

The latest round of changes to the refetching implementation has papered over this issue in GateGuru. Kicking this one to 0.20.1 to focus on non-academic problems.

@blakewatters
Member

Closed by new implementation of refetching support.

@dostrander

Hey is this fixed because I am getting an error when I am trying to get a user through /user/id.json. the response is laid out like
user{
dogs[
0:{
...
alerts: []
}
]
}

object mapping. Results: {
"" = "<User: 0x1ea1ece0> (entity: User; id: 0x1e959b00 x-coredata://AF6670D1-FCA2-411F-8D26-A3745E1DCC9E/User/p4 ; data: {\n authToken = gJK3CdZC9K9FpQ86naJe;\n dogs = (\n "0x1ddc3d50 x-coredata://AF6670D1-FCA2-411F-8D26-A3745E1DCC9E/Dog/p1"\n );\n email = "bjweinre@syr.edu";\n firstName = Brian;\n iD = 1;\n lastName = Weinreich;\n})";
}
2013-01-23 11:26:56.308 Dogdid[1481:1903] W restkit.core_data:RKManagedObjectRequestOperation.m:555 Caught undefined key exception for keyPath 'alerts' in mapping result: This likely indicates an ambiguous keyPath is used across response descriptor or dynamic mappings.

@blakewatters
Member

Update to the development branch. The change has been merged, but not yet released in a tagged version.

@stojanovicigi stojanovicigi added a commit to CenterDevice/RestKit that referenced this issue Dec 12, 2013
@blakewatters @stojanovicigi blakewatters + stojanovicigi Add temporary workaround for crashes related to ambiguous key paths i…
…n the deletion support. refs #1111
2d6674a
@stojanovicigi stojanovicigi added a commit to CenterDevice/RestKit that referenced this issue Dec 12, 2013
@blakewatters @stojanovicigi blakewatters + stojanovicigi Rework implementation of managed object deletion and refetching to us…
…e the refreshed visitor implementation. refs #1111, #1113
cf799ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment