parent_ids field always empty list in merge request commits response

Summary

According to the documentation for getting the commits for a merge request, the parent_ids field will contain the git hashes of the parent commits of a given commit. The actual API returns all commits with the parent_ids field set to empty list: []

Steps to reproduce

I can hit the API in my browser and see commits listed which all have parent_ids: []. Example API URL in the gitlab project: https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/merge_requests/167144/commits.

What is the current bug behavior?

The parent_ids field is an empty list.

What is the expected correct behavior?

The parent_ids field should be a list that contains the hashes of all parents.

Relevant logs and/or screenshots

Screenshot_2024-09-30_at_17.48.37

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Investigation (by @vyaklushin)

merge_request.merge_request_diff.merge_request_diff_commits returns MergeRequestDiffCommit objects that don't include parent_ids. After converting them to Commit object it's missing parent_ids as well.

source

Edited by Vasilii Iakliushin