Skip to content

Update DiffNote's line_range during importing

What does this MR do and why?

This MR fixes an issue during Project Import where some diff notes of merge requests can fail to import with the following error: RecordInvalid - Position must be a valid json schema. Error is coming from JsonSchemaValidator when validating record.position.

DiffNote has position/original_position/change_position attributes that contain line_range information about the diff. Some DiffNotes can have an outdated line_range information which gets exported and fails to be imported due to an invalid schema. Not a lot of such notes have outdated line_range format, but some of them still do. For this reason I am adding the conversion during import, if outdated format is detected.

Old format looks like this:

{ line_range: { start_line_code: 'abc_0_1', start_line_type: 'new', end_line_code: 'abc_0_1', end_line_type: 'new' } }.

New format looks like this:

{ start: { line_code: 'abc_0_1', type: 'new', old_line: 0, new_line: 1 }, end: { line_code: 'abc_0_1', type: 'new', old_line: 0, new_line: 1 } }

Update diffnote's line_range information to the latest format during the import in order to successfully import outdated diff notes.

Mentions #440685 (closed)

MR acceptance checklist

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

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by George Koltsov

Merge request reports