Creating a Merge Request via the API returns null: sha, base_sha and head_sha

We are currently using the merge request API to create a new MR. A number of our clients are consistently getting back a number of null values which according to the docs should not be null.

Here is an example response (fake data, but format is equivalent), pay attention to the fields below all of which are null:

  • sha
  • diff_refs.base_sha
  • diff_refs.head_sha
{
    "id": 123456789,
    "iid": 17,
    "project_id": 12345678,
    "title": "Some title",
    "description": "",
    "state": "opened",
    "created_at": "2022-06-21T14:41:00.589Z",
    "updated_at": "2022-06-21T14:41:00.589Z",
    "merged_by": null,
    "merge_user": null,
    "merged_at": null,
    "closed_by": null,
    "closed_at": null,
    "target_branch": "QA",
    "source_branch": "My-Feature-Branch",
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "author": {
        "id": 12345678,
        "username": "My-Username",
        "name": "My Name",
        "state": "active",
        "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/12345678/avatar.png",
        "web_url": "https://gitlab.com/My-Username"
    },
    "assignees": [],
    "assignee": null,
    "reviewers": [],
    "source_project_id": 12345678,
    "target_project_id": 12345678,
    "labels": [],
    "draft": false,
    "work_in_progress": false,
    "milestone": null,
    "merge_when_pipeline_succeeds": false,
    "merge_status": "checking",
    "sha": null,
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": null,
    "reference": "!17",
    "references": {
        "short": "!17",
        "relative": "!17",
        "full": "My-Repository/my-project!17"
    },
    "web_url": "https://gitlab.com/my-Repository/my-project/-/merge_requests/17",
    "time_stats": {
        "time_estimate": 0,
        "total_time_spent": 0,
        "human_time_estimate": null,
        "human_total_time_spent": null
    },
    "squash": false,
    "task_completion_status": {
        "count": 0,
        "completed_count": 0
    },
    "has_conflicts": false,
    "blocking_discussions_resolved": true,
    "approvals_before_merge": null,
    "subscribed": true,
    "changes_count": null,
    "latest_build_started_at": null,
    "latest_build_finished_at": null,
    "first_deployed_to_production_at": null,
    "pipeline": null,
    "head_pipeline": null,
    "diff_refs": {
        "base_sha": null,
        "head_sha": null,
        "start_sha": "625b19b69cb992e6f6b00044dfe6d77af09c687c"
    },
    "merge_error": null,
    "user": {
        "can_merge": true
    }
}

And here is the payload we send:

api/v4/projects/123456789/merge_request

{   
    "id": "12345678",   
    "title": "Some title",   
    "source_branch": "My-Feature-Branch",   
    "target_branch": "QA",   
    "description": "some description" 
}

I couldn't find anything in your docs (or forums) which mentions how this might happen. I haven't personally been able to reproduce it but our customer is consistently running into this. They are using the hosted version of GitLab (not self-managed).

Any advice would be appreciated, happy to also provide more info.