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 after mutating model that removes a references within resolveRelationships when cached. #121

Open
Jeroenbb94 opened this issue Oct 5, 2021 · 0 comments

Comments

@Jeroenbb94
Copy link

When updating a Contentful object type that removes an existing relationship with another Contentful object type, will resolve in an app crash when trying to resolve this relationship from cachedUnresolvedRelationships.

For example I have a ContentfulDashboardItem Content Type with a reference to ContentfulColor Content Type called backgroundColor. When I update the ContentfulDashboardItem Content Type that removes the reference to ContentfulColor Content Type and restart my app, 9 out of 10 times it works as expected. Though when the SynchronizationManager.swift find unresolved relationships (see cachedUnresolvedRelationships variable), the app will crash because the reference backgroundColor does not exist anymore.

The crash log:

Fatal Exception: NSUnknownKeyException
[<ContentfulDashboardItem 0x28290af80> setValue:forUndefinedKey:]: the entity ContentfulDashboardItem is not key value coding-compliant for the key "backgroundColor".

The line (220) where it crashes in SynchronizationManager.swift:

entryPersistable.setValue(target, forKey: fieldName)

Could the resolve relationships be updated so that it first checks if it can call setValue before calling it and making it crash?

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

1 participant