Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeRequestDiscussions.create Request-URI Too Large #3478

Closed
2 tasks done
JordiVanOs opened this issue Nov 30, 2023 · 1 comment · Fixed by #3479
Closed
2 tasks done

MergeRequestDiscussions.create Request-URI Too Large #3478

JordiVanOs opened this issue Nov 30, 2023 · 1 comment · Fixed by #3479
Labels
released This issue/pull request has been released.

Comments

@JordiVanOs
Copy link

Description

  • Node.js version: v18.16.0
  • Gitbeaker version: 39.21.2
  • Gitbeaker release (cli, node, browser, core, requester-utils): node
  • OS & version: macOS Sonoma 14.0

The following API usage results in an Request-URI Too Large error:

MergeRequestDiscussions.create(projectId, mergeRequestId, body);
// Error: Request-URI Too Large
//     at throwFailedRequestError ([...]/@gitbeaker/rest/dist/index.js:75:9)

Steps to reproduce

  1. Create a Gitlab API instance with the host set to https://gitlab.com/api and a valid API token
  2. Call MergeRequestDiscussions.create with a body of containing more than 10000 characters
  3. See error

Expected behaviour

To have not resulted in an error, since the character limit seems to be way higher than 10k (I can manually place a comment with 610k characters).

Actual behaviour

An Request-URI Too Large error

Possible fixes

The request sent to Gitlab's REST API seems to append the body as a URI parameter, instead of sending it as an actual JSON body. Rewriting my code using the fetch API fixes this issue for me:

async createMergeRequestDiscussion(projectId: string, mergeRequestId: number, body: string) {
    await fetch(path.join(this.api.url, `/projects/${projectId}/merge_requests/${mergeRequestId}/discussions`), {
        method: 'POST',
        headers: {
            'PRIVATE-TOKEN': process.env.GITLAB_TOKEN!!,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({body})
    });
}

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.
@jdalrymple
Copy link
Owner

🚀 Issue was released in 39.26.0 🚀

@jdalrymple jdalrymple added the released This issue/pull request has been released. label Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants