Merge Request commits API never populates trailers
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=505825)
</details>
<!--IssueSummary end-->
<!---
Please read this!
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "regression" or "type::bug" label:
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug
and verify the issue you're about to submit isn't a duplicate.
--->
### Summary
The commits returned by the `GET /projects/:id/merge_requests/:merge_request_iid/commits` [API](https://docs.gitlab.com/ee/api/merge_requests.html#get-single-merge-request-commits) always returns empty `commits[].trailers` and `commits[].extended_trailers` attributes.
The `commit[].trailers` attribute is documented for merge request commits here: https://docs.gitlab.com/ee/api/merge_requests.html#get-single-merge-request-commits
### Example Project
Merge request commit has empty trailers:
``` sh
$ curl --silent "https://gitlab.com/api/v4/projects/278964/merge_requests/136998/commits" | jq
[
{
"id": "f4ad42c30a33a04bc49598abfcfe39499327dfba",
"short_id": "f4ad42c3",
"created_at": "2023-11-24T13:37:46.000Z",
"parent_ids": [],
"title": "Introduce `extended_trailers` field in commits API",
"message": "Introduce `extended_trailers` field in commits API\n\nAdds a new field that correctly supports all commit trailers. Unlike\nthe existing `trailers` field, this will return an array of values\nwhere the same key is used multiple times, e.g. \"Cc\".\n\nThis functionality will eventually be moved over to the `trailers`\nfield once the original functionality has been deprecated. This\nis a breaking change to the API and therefore can't be performed\nin this commit.\n\nChangelog: added\n",
"author_name": "Robert May",
"author_email": "rmay@gitlab.com",
"authored_date": "2023-11-15T13:09:14.000Z",
"committer_name": "Robert May",
"committer_email": "rmay@gitlab.com",
"committed_date": "2023-11-24T13:37:46.000Z",
"trailers": {},
"extended_trailers": {},
"web_url": "https://gitlab.com/gitlab-org/gitlab/-/commit/f4ad42c30a33a04bc49598abfcfe39499327dfba"
}
]
```
Repository commits for the same ref similar has no trailers when `trailers=True` not passed
``` sh
$ curl --silent "https://gitlab.com/api/v4/projects/278964/repository/commits?ref_name=f4ad42c30a33a04bc49598abfcfe39499327dfba^-1" | jq
[
{
"id": "f4ad42c30a33a04bc49598abfcfe39499327dfba",
"short_id": "f4ad42c3",
"created_at": "2023-11-24T13:37:46.000+00:00",
"parent_ids": [
"8be0f7f78be14ca09828fe794f44e68465e33235"
],
"title": "Introduce `extended_trailers` field in commits API",
"message": "Introduce `extended_trailers` field in commits API\n\nAdds a new field that correctly supports all commit trailers. Unlike\nthe existing `trailers` field, this will return an array of values\nwhere the same key is used multiple times, e.g. \"Cc\".\n\nThis functionality will eventually be moved over to the `trailers`\nfield once the original functionality has been deprecated. This\nis a breaking change to the API and therefore can't be performed\nin this commit.\n\nChangelog: added\n",
"author_name": "Robert May",
"author_email": "rmay@gitlab.com",
"authored_date": "2023-11-15T13:09:14.000+00:00",
"committer_name": "Robert May",
"committer_email": "rmay@gitlab.com",
"committed_date": "2023-11-24T13:37:46.000+00:00",
"trailers": {},
"extended_trailers": {},
"web_url": "https://gitlab.com/gitlab-org/gitlab/-/commit/f4ad42c30a33a04bc49598abfcfe39499327dfba"
}
]
```
Repository commits return the trailers if `trailer=True` is passed:
``` sh
$ curl --silent "https://gitlab.com/api/v4/projects/278964/repository/commits?ref_name=f4ad42c30a33a04bc49598abfcfe39499327dfba^-1&trailers=True" | jq
[
{
"id": "f4ad42c30a33a04bc49598abfcfe39499327dfba",
"short_id": "f4ad42c3",
"created_at": "2023-11-24T13:37:46.000+00:00",
"parent_ids": [
"8be0f7f78be14ca09828fe794f44e68465e33235"
],
"title": "Introduce `extended_trailers` field in commits API",
"message": "Introduce `extended_trailers` field in commits API\n\nAdds a new field that correctly supports all commit trailers. Unlike\nthe existing `trailers` field, this will return an array of values\nwhere the same key is used multiple times, e.g. \"Cc\".\n\nThis functionality will eventually be moved over to the `trailers`\nfield once the original functionality has been deprecated. This\nis a breaking change to the API and therefore can't be performed\nin this commit.\n\nChangelog: added\n",
"author_name": "Robert May",
"author_email": "rmay@gitlab.com",
"authored_date": "2023-11-15T13:09:14.000+00:00",
"committer_name": "Robert May",
"committer_email": "rmay@gitlab.com",
"committed_date": "2023-11-24T13:37:46.000+00:00",
"trailers": {
"Changelog": "added"
},
"extended_trailers": {
"Changelog": [
"added"
]
},
"web_url": "https://gitlab.com/gitlab-org/gitlab/-/commit/f4ad42c30a33a04bc49598abfcfe39499327dfba"
}
]
```
### What is the current *bug* behavior?
The `commits[].trailers` attribute is always empty when returned by `/projects/:id/merge_requests/:merge_request_iid/commits` even when the commits contain trailers.
### What is the expected *correct* behavior?
That the `commits[].trailers` are populated for merge request commits.
### Relevant logs and/or screenshots
<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code
as it's tough to read otherwise. -->
### Output of checks
<!-- If you are reporting a bug on GitLab.com, uncomment below -->
<!-- This bug happens on GitLab.com -->
<!-- and uncomment below if you have /label privileges -->
<!-- /label ~"reproduced on GitLab.com" -->
<!-- or follow up with an issue comment of `@gitlab-bot label ~"reproduced on GitLab.com"` if you do not -->
#### Results of GitLab application Check
Seen on GitLab.com
### Possible fixes
The issue _might_ be due to the fact that the `/projects/:id/merge_requests/:merge_request_iid/commits` API does not accept a `trailers` boolean to enable these attributes unlike the `/projects/:id/repository/commits` API which does have the boolean input value: https://docs.gitlab.com/ee/api/commits.html#list-repository-commits (assuming these perhaps share the same backend code).
Adding the `trailers=<True|False>` input option to the `/projects/:id/merge_requests/:merge_request_iid/commits` would allow the trailers to be returned in the same way they are for repository commits.
`GET /projects/:id/repository/commits/:sha` also does not return trailers, though it would very useful if that did too.
`https://docs.gitlab.com/ee/api/commits.html#get-a-single-commit`
<!-- If you don't have /label privileges, follow up with an issue comment of `@gitlab-bot label ~"type::bug"` -->
issue