Skip to content

Fix infinite loop when parsing nested associations#539

Open
gordysc wants to merge 3 commits into
remi:masterfrom
kalkomey:master
Open

Fix infinite loop when parsing nested associations#539
gordysc wants to merge 3 commits into
remi:masterfrom
kalkomey:master

Conversation

@gordysc
Copy link
Copy Markdown

@gordysc gordysc commented Sep 10, 2020

It appears with this commit a potential infinite loop was introduced if models defined both has_many/belongs_to.

To mitigate this, I've added a straightforward check for belongs_to to no-op if the association is already defined on the resulting object. Also, sorry for the previous PR! Moved this under my company's organization for easy access to the rest of my team.

Finally, it appears we're now respecting included_root_element for nested associations. This PR also adds an option to opt out of this new behavior as well as potentially use a different name via included_embedded_root_element

@gabrielrdrguez
Copy link
Copy Markdown

gabrielrdrguez commented Sep 15, 2021

Somebody please give a medal to this man! (and merge this PR 😛 )

voltechs added a commit to TwilightCoders/her that referenced this pull request Mar 31, 2026
Ref: remi#539

The infinite loop reported in remi#539 is already prevented by caching
the inverse association through the proxy (commit 74bc996) rather
than injecting it into the attributes hash. These tests confirm the
fix holds for to_params with bidirectional associations.
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

Successfully merging this pull request may close these issues.

3 participants