Description:
Prerequisites
Setup Configuration and Environment
require("gitlab").setup()
Using .gitlab.nvim file with auth_token and gitlab_url for a self-hosted GitLab instance.
Bug Description
Calling choose_merge_request() without arguments (e.g. via the default glc keybinding) fails with:
Could not parse JSON request body: json: cannot unmarshal array into Go value of type gitlab.ListProjectMergeRequestsOptions
The cause is in lua/gitlab/state.lua line 565 - the merge_requests dependency's body function returns opts or {}. In Lua, an empty table {} with no string keys is encoded by vim.json.encode as a JSON array [], but the Go server expects a JSON object {}.
Calling with an explicit option works: :lua require("gitlab").choose_merge_request({ state = "opened" }).
Fix: Change return opts or {} to return opts or vim.empty_dict() in lua/gitlab/state.lua line 565. vim.empty_dict() ensures the value is encoded as a JSON object.
Reproduction Steps
- Open Neovim in a GitLab project directory with a valid
.gitlab.nvim config
- Press
glc or run :lua require("gitlab").choose_merge_request()
- Observe error:
"Could not parse JSON request body"
Screenshots
Server log showing the issue:
-- REQUEST TO GO SERVER --
POST /merge_requests HTTP/1.1
...
[]
-- RESPONSE FROM GO SERVER --
HTTP/0.0 400 Bad Request
...
{"message":"Could not parse JSON request body","details":"json: cannot unmarshal array into Go value of type gitlab.ListProjectMergeRequestsOptions"}
Description:
Prerequisites
:h gitlab.nvim.troubleshootingand followed the steps thereSetup Configuration and Environment
Using
.gitlab.nvimfile withauth_tokenandgitlab_urlfor a self-hosted GitLab instance.Bug Description
Calling
choose_merge_request()without arguments (e.g. via the defaultglckeybinding) fails with:The cause is in
lua/gitlab/state.lualine 565 - themerge_requestsdependency'sbodyfunction returnsopts or {}. In Lua, an empty table{}with no string keys is encoded byvim.json.encodeas a JSON array[], but the Go server expects a JSON object{}.Calling with an explicit option works:
:lua require("gitlab").choose_merge_request({ state = "opened" }).Fix: Change
return opts or {}toreturn opts or vim.empty_dict()inlua/gitlab/state.lualine 565.vim.empty_dict()ensures the value is encoded as a JSON object.Reproduction Steps
.gitlab.nvimconfigglcor run:lua require("gitlab").choose_merge_request()"Could not parse JSON request body"Screenshots
Server log showing the issue: