Open vprevosto opened 1 month ago
Thanks for reporting the issue @vprevosto
Could you include the URL (or an example of it) that you're requesting? Running your code with GITLAB_DEBUG=1
should print out this information.
The field for approvals_before_merge
is deprecated and scheduled for removal https://docs.gitlab.com/ee/api/merge_requests.html#removals-in-api-v5
Thanks for your answer. Here is an example (note that this is private repo, you can't access it as of now)
>>> GitLab: Requesting https://git.frama-c.com/api/v4/projects/virgile%2Ftest-ocaml-gitlab/merge_requests
>>> GitLab: Response code 200 OK
>>> GitLab: response body:
[
{
"id": 9799,
"iid": 1,
"project_id": 1567,
"title": "clean up README",
"description": "",
"state": "opened",
"created_at": "2024-10-25T08:37:41.810Z",
"updated_at": "2024-10-25T08:37:42.953Z",
"merged_by": null,
"merge_user": null,
"merged_at": null,
"closed_by": null,
"closed_at": null,
"target_branch": "main",
"source_branch": "test-branch",
"user_notes_count": 0,
"upvotes": 0,
"downvotes": 0,
"author": {
"id": 23,
"username": "virgile",
"name": "Virgile Prevosto",
"state": "active",
"locked": false,
"avatar_url": "https://secure.gravatar.com/avatar/a011a10334ec22fe7e7317c48be6ef8d83cf2ed986b3623586fbc574a3ef4b44?s=80&d=identicon",
"web_url": "https://git.frama-c.com/virgile"
},
"assignees": [],
"assignee": null,
"reviewers": [],
"source_project_id": 1567,
"target_project_id": 1567,
"labels": [],
"draft": false,
"imported": false,
"imported_from": "none",
"work_in_progress": false,
"milestone": null,
"merge_when_pipeline_succeeds": false,
"merge_status": "can_be_merged",
"detailed_merge_status": "mergeable",
"sha": "8cf32e96a9fc282a0ea6989b61db1f5004b00ce7",
"merge_commit_sha": null,
"squash_commit_sha": null,
"discussion_locked": null,
"should_remove_source_branch": null,
"force_remove_source_branch": true,
"prepared_at": "2024-10-25T08:37:42.950Z",
"reference": "!1",
"references": {
"short": "!1",
"relative": "!1",
"full": "virgile/test-ocaml-gitlab!1"
},
"web_url": "https://git.frama-c.com/virgile/test-ocaml-gitlab/-/merge_requests/1",
"time_stats": {
"time_estimate": 0,
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
},
"squash": false,
"squash_on_merge": false,
"task_completion_status": { "count": 0, "completed_count": 0 },
"has_conflicts": false,
"blocking_discussions_resolved": true
}
]
and then the error Fatal error: exception Failure("Bad response: Atdgen_runtime.Oj_run.Error(\"Line 1:\\nMissing record field merge_request_approvals_before_merge\")...
For the record, this is obtained from the small script below, linked against gitlab-unix
let base_uri = Uri.of_string "https://git.frama-c.com/api/v4"
let add_path uri path = Uri.with_path uri (Uri.path uri ^ "/" ^ path)
let token = Sys.getenv "GITLAB_TOKEN";;
let token = Gitlab.Token.AccessToken token;;
let path = "projects/virgile%2ftest-ocaml-gitlab/merge_requests";;
let uri = add_path base_uri path;;
let parse s = Lwt.return (Gitlab_j.merge_requests_of_string s);;
let do_one_mr mr =
Gitlab.Monad.return
(Printf.printf "This is MR %d: %s\n%!"
mr.Gitlab_t.merge_request_iid mr.Gitlab_t.merge_request_title);;
let request = Gitlab.API.get_stream ~token ~uri parse;;
let iter_req = Gitlab.Stream.iter do_one_mr request;;
let () = iter_req |> Gitlab.Monad.run |> Lwt_main.run;;
While toying with the library to get some merge requests from our gitlab server, I was met with
Making this field optional in
gitlab.atd
(where it is alreadynullable
) by adding a?
in front of the name makes the problem disappear.