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

Crash During Orphaned Managed Object with Ambiguous KeyPaths #1111

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

Crash During Orphaned Managed Object with Ambiguous KeyPaths #1111

blakewatters opened this issue Dec 27, 2012 · 5 comments
Assignees
Labels
Milestone

Comments

@blakewatters
Copy link
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.
@ghost ghost assigned blakewatters Dec 27, 2012
blakewatters added a commit that referenced this issue Dec 27, 2012
blakewatters added a commit that referenced this issue Dec 29, 2012
@blakewatters
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

Closed by new implementation of refetching support.

@dostrander
Copy link

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
Copy link
Member Author

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

4PixelsDev pushed a commit to CenterDevice/RestKit that referenced this issue Dec 12, 2013
4PixelsDev pushed a commit to CenterDevice/RestKit that referenced this issue Dec 12, 2013
4PixelsDev pushed a commit to CenterDevice/RestKit that referenced this issue Dec 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants