Fix Note note and note_html replacement when nil
What does this MR do and why?
We have overridden both note and note_html methods in the Note model so we can be consistent with the system note naming. Tis is only necessary until the background migration to replace the text on all system notes is run. Migration was merged in 15.4 but still hasn't finished running in .com
We will soon remove this methods, but while they are there, we need to handle the fact that even if we validate the presence of note, some project importers (like the github importer) might introduce nil note_html. Sop this small change simply doesn't fail if note or note_html is nil by using the safe operator. The same logic is maintained
How to validate locally
- Create an issue with a note.
- Find that note in the console (bin/rails c)
issue.notes.first - Update the note without validations
note.update_columns(note: nil, note_html: nil) - Use the API to query the note with a query like:
{
issue(id: "gid://gitlab/Issue/675") {
notes {
nodes {
id
body
bodyHtml
}
}
}
}
Before this change you should get a 500 Internal server error: undefined method match?' for nil:NilClass`
This has no effect on the main issue view at /<project_path>/-/issues/
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #368028 (closed)