Change to approval rule hook breaks pre-change approval rules
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=492640) </details> <!--IssueSummary end--> <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "type::bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary A customer reported an issue via [this (internal only) ticket](https://gitlab.zendesk.com/agent/tickets/561519) where the existing system hook started returning an incorrect value for approval rules. The incorrect value looks like this: ``` "approval_rules":{"previous":"#<ApprovalMergeRequestRule::ActiveRecord_Associations_CollectionProxy:0x00007f1728f9d8a0>","current": [{...valid json}]} ``` ### Steps to reproduce * This requires having a pre 17.0.6 instance, MR's, approval rules and hooks in place * Upgrading to 17.0.6 will cause the pre-17.0.6 approval rules to use https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138564/diffs?file=7efdd02a127f378855725acd8f695b0a69325cea#7efdd02a127f378855725acd8f695b0a69325cea_682_683 * The ActiveRecord_Associations_CollectionProxy will be returned ### Example Project N/A ### What is the current _bug_ behavior? While cached, hooks return via `previous` ActiveRecord_Associations_CollectionProxy if approval rules are changed ### What is the expected _correct_ behavior? The array should be returned ### Relevant logs and/or screenshots N/A ### Output of checks N/A ### Possible fixes Because of its transient nature, it's possible that this has been present before and just gone away as things are updated. Maybe ```ruby assoc.fetch(:approval_rules, approval_rules).to_a ``` In https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/concerns/ee/issuable.rb#L96 ?
issue