Skip to content

Fix MR discussion not loaded issue

What does this MR do?

Some MR discussions aren't being loaded, because its json endpoint return 500.
The error was caused by json generation causing IOError: not opened for reading.
One possible cause might be that the Position object could trigger a as_json call to its diff_file instance variable, which in turn triggers as_json on repository, which is not serializable and causes the IOError.

Error report: https://sentry.gitlab.net/gitlab/gitlabcom/issues/515862/

Currently the position hash contains a formatter hash.

This MR removes the nesting, so position hash will have what the formatter hash contains. This removes the unneeded diff_file, and thus avoids the error all together.

Current:

{
   "position": {
    "formatter": {
      "base_sha":"xxx",
      "start_sha":"xxx",
      "head_sha":"xxx",
      "old_path":".jscsrc",
      "new_path":".jscsrc",
      "position_type":"text",
      "old_line":null,
      "new_line":1 
     }
  }
}

After this MR

{
   "position": {
      "base_sha":"xxx",
      "start_sha":"xxx",
      "head_sha":"xxx",
      "old_path":".jscsrc",
      "new_path":".jscsrc",
      "position_type":"text",
      "old_line":null,
      "new_line":1 
     }
}

What are the relevant issue numbers?

#51958 (closed)

Does this MR meet the acceptance criteria?

Closes #51958 (closed)

Edited by Mark Chao

Merge request reports

Loading