Fix error when displaying discussions with note without an author
What does this MR do?
When requesting for Projects::MergeRequestsController#discussions
action and one of the notes has no author (for some reason), it'll result to a NoMethodError
. This is because in Note#post_processed_cache_key
we get the cache key of the author.
In this MR, we don't get the cache_key
of author anymore if it's not present to prevent this error.
We don't display notes without an author though (after testing locally) so the note will still not be displayed but this will at least prevent the entire request from failing.
No changelog trailer since the caching feature is still behind a feature flag (merge_request_discussion_cache
).
Does this MR meet the acceptance criteria?
Conformity
-
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.)
Related to #339704 (closed)
Edited by Patrick Bajao