Discussion API / Create new commit thread seemingly doesn't work on the initial (parentless) commit

Summary

Discussion API / Create new commit thread seemingly doesn't work on the initial (parentless) commit - results in various errors depending on a parameters.

Steps to reproduce

Take any repository with at leas one commit and try to comment any file in the initial commit of this repository the above mentoined using API.

Example Project

(If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report)

(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)

What is the current bug behavior?

See attached cc.batcc.log As may be seen from them the API fails even if parameters are exactly the same (save the body) as for discussion created via UI.

What is the expected correct behavior?

Successfully created discussion (along with a clear description in the documentation to which values position[base_sha] and position[start_sha] have to be set in such case).

Relevant logs and/or screenshots

C:\tmp\glapi-testbed>curl  --request GET --header "PRIVATE-TOKEN: GaPWCNiLxA33Asbc1zs6"   https://main.gitlab.in.here.com/api/v4/projects/ce%2Fpublication-services%2Fnds%2Fpoc%2Fglapi-testbed/repository/commits/3d1aad7a007576e62df491a48886165cb898c8f0   | python -m json.tool 
{
    "author_email": "oleksandr.alesinskyy@here.com",
    "author_name": "Alesinskyy, Oleksandr",
    "authored_date": "2019-10-25T15:24:49.000Z",
    "committed_date": "2019-10-25T15:24:49.000Z",
    "committer_email": "oleksandr.alesinskyy@here.com",
    "committer_name": "Alesinskyy, Oleksandr",
    "created_at": "2019-10-25T15:24:49.000Z",
    "id": "3d1aad7a007576e62df491a48886165cb898c8f0",
    "last_pipeline": null,
    "message": "Initial commit",
    "parent_ids": [],
    "project_id": 2606,
    "short_id": "3d1aad7a",
    "stats": {
        "additions": 3,
        "deletions": 0,
        "total": 3
    },
    "status": null,
    "title": "Initial commit"
}

C:\tmp\glapi-testbed>curl  --request GET --header "PRIVATE-TOKEN: GaPWCNiLxA33Asbc1zs6"   https://main.gitlab.in.here.com/api/v4/projects/ce%2Fpublication-services%2Fnds%2Fpoc%2Fglapi-testbed/repository/commits/3d1aad7a007576e62df491a48886165cb898c8f0/discussions    | python -m json.tool 
[
    {
        "id": "251a3ac1ca7b74b040bd7fc1ad4252482cbf9c02",
        "individual_note": false,
        "notes": [
            {
                "attachment": null,
                "author": {
                    "avatar_url": "https://main.gitlab.in.here.com/uploads/-/system/user/avatar/1463/avatar.png",
                    "id": 1463,
                    "name": "Alesinskyy, Oleksandr",
                    "state": "active",
                    "username": "oalesins",
                    "web_url": "https://main.gitlab.in.here.com/oalesins"
                },
                "body": "Via UI",
                "created_at": "2019-11-22T06:44:48.188-06:00",
                "id": 477480,
                "noteable_id": null,
                "noteable_iid": null,
                "noteable_type": "Commit",
                "position": {
                    "base_sha": "0000000000000000000000000000000000000000",
                    "head_sha": "3d1aad7a007576e62df491a48886165cb898c8f0",
                    "new_line": 3,
                    "new_path": "README.md",
                    "old_line": null,
                    "old_path": "README.md",
                    "position_type": "text",
                    "start_sha": "0000000000000000000000000000000000000000"
                },
                "resolvable": false,
                "system": false,
                "type": "DiffNote",
                "updated_at": "2019-11-22T06:47:37.957-06:00"
            }
        ]
    }
]

C:\tmp\glapi-testbed>curl  --request POST --header "PRIVATE-TOKEN: GaPWCNiLxA33Asbc1zs6" --form "body=Via API"   --form "position[new_path]=README.md"   --form "position[old_path]=README.md"   --form "position[new_line]=1"      --form "position[old_line]=1"      --form "position[base_sha]=0000000000000000000000000000000000000000"   --form "position[head_sha]=3d1aad7a007576e62df491a48886165cb898c8f0"   --form "position[start_sha]=0000000000000000000000000000000000000000"   --form "position[position_type]=text"   https://main.gitlab.in.here.com/api/v4/projects/ce%2Fpublication-services%2Fnds%2Fpoc%2Fglapi-testbed/repository/commits/3d1aad7a007576e62df491a48886165cb898c8f0/discussions    | python -m json.tool 
{
    "message": "400 (Bad request) \"Note {:line_code=>[\"can't be blank\", \"must be a valid line code\"]}\" not given"
}

See as well https://support.gitlab.com/hc/en-us/requests/138005?page=1

See cc.log for a full log.

Output of checks

(If you are reporting a bug on GitLab.com, write: 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)

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Oleksandr Alesinskyy