Update diff note representation

What does this MR do and why?

Adds a check for nil hunks on PR/MR diffs to avoid no method errors when importing from github.

Errors were reported when importing from GitHub to GitLab Enterprise 18.5.1-ee

"exception_class": "NoMethodError", "exception_message": "undefined method `new_pos' for nil:NilClass", "source": "Gitlab::GithubImport::Importer::DiffNoteImporter"

The errors appeared to correlate with the roll-out of a beta feature on GitHub.

It was noted in the Github UI that some PRs had some unusual hidden comments that were only visible if the feature was enabled in the UI. This may have caused Github's data model to drift.

This initial fix updates the Representation::DiffNote class to handle nil diff hunks, however further investigation needs to be done to see if the GH data model has shifted and how this impacts diff note import.

This fix generates a diff_hunk when it is nil or empty. It finds the code context by querying the repository blob.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #580193 (closed)

Edited by Carla Drago

Merge request reports

Loading