fix(kitsu-core): fix inability to link relationship links on circular resources#699
Conversation
Even though it passed as-is, I think it's a good idea to keep the test as it's extra redundency to protect against regressions
The code path is either:
|
Co-authored-by: James Harris <wopian@wopian.me>
|
Code Climate has analyzed commit 0d55779 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (100% is the threshold). This pull request will bring the total coverage in the repository to 100.0% (0.0% change). View more on Code Climate. |
|
@wopian Turns out i spoke too soon regarding the array case. I'll go squash the commits in preparation for the merge when you give the OK |
|
You don't need to squash the commits, the PR merge itself squashes them 👍
Good spot! D: |
|
Thank you! 🎉 |
|
Released in 10.0.0-alpha.26 |
Before this fix, this error would occasionally pop up
When serializing a resource with a once removed relationship to itself (A -> B -> A).
The problem seems to stem from same origin as this issue #579, where a
relationshipsobject is deleted before subsequent objects with references to it has had a change to read itThe simple solution would be to add safe navigation to the
ifstatement, but thenmetaandlinkswould be lost on any subsequent inclusions of the resource.I was unable to reproduce this issue with array resource linkages, so only
linkObjectwas modified. I have a feeling it might be due to something relating to pass-by-value/pass-by-reference. I wrote a spec for it, and it passed without modification, so i just removed it again. I can add it back if you think it would be relevantI'm very open to style changes or suggestions for alternate implementations