Gitlab Draft-note API bug when posting multi-line comments
-
Start this issue's title with Docs:orDocs feedback:.
Problem to solve
When using the GitLab Draft Notes API: https://docs.gitlab.com/api/draft_notes/#create-a-draft-note, we are trying to post multi-line comments using the position arguments. We followed this https://docs.gitlab.com/api/discussions/#parameters-for-multiline-comments to fill the parameters, however GitLab is throwing An error occurred: 400 (An error occurred: 400 ({"message":{"position":["must be a valid json schema"]}})) when we send old_line, new_line parameters in position[line_range][start] argument.
We are providing the correct line_code. If we remove the old_line and new_line parameters (which are optional), the multi-line comment works, but it doesn't show the comment line badge in the UI.
However, I was also facing issue with line_code field. As an example, I posted this multi-line comment through UI and inspected the network call. This is their line_range param:
{
start: {
line_code: "****************************************_33_34",
type: "old",
old_line: 33,
new_line: null
},
end: {
line_code: "****************************************_36_36",
type: "new",
old_line: null,
new_line: 36
}
}
The comments were applied from -33 to +36. Based on this, not sure how <old_line> and <new_line> are computed in the line_code: <SHA>_<old_line>_<new_line> as 33_34 for start, and 36_36 for end.
To summarize the issues that we are observing
- If I send
old_lineandnew_lineparams inline_range(we took this information from the network calls, so our request was exactly the same as the network call) GitLab throws({"message":{"position":["must be a valid json schema"]}})) - The
line_codeformat recommended in the doc does not matches what I'm seeing in the network calls while making multi-line comment from the UI. But if I use the same line_code from code, it does works. So not clear on the proper recommendation ofline_codeformat.
Proposal
Could you please test this API and provide further documentation and examples on use or if there is a bug on Gitlab's side could get an estimate of the fix.