-
Stan Hu authored
Previously a note on a merge request would be committed to the database before its `type` is promoted to `DiscussionNote`. However, as we saw in https://gitlab.com/gitlab-org/gitlab/-/issues/301237, if a user replies to an individual note on the merge request but the UPDATE to the note fails (e.g. due to a SQL timeout), the note will persist in the database but have the wrong discussion `type`. This can block users from being able to merge a merge request because the backend will detect an unresolved discussion. However, the UI won't show any unresolved discussions because the first note will erroneously appear to be an individual note, which cannot be resolved since it's not a discussion. To avoid this issue, we now promote the `type` within the save transaction so that the note will always persist with the right value. Closes https://gitlab.com/gitlab-org/gitlab/-/issues/301237
5a160b7f