gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

MergeRequestApi getDiffs() returns 500 Internal Server Error

Open sjyzheng opened this issue 1 year ago • 2 comments

Hi team, I am trying to use the MergeRequestApi getDiffs to retrieve the MR diff. val mergeRequestDiff = api.mergeRequestApi.getDiffs(projectID, mergeRequestIId) It returns 500 Internal Server Error. org.gitlab4j.api.GitLabApiException: 500 Internal Server Error at org.gitlab4j.api.AbstractApi.validate(AbstractApi.java:678) at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:214) at org.gitlab4j.api.Pager.<init>(Pager.java:92) at org.gitlab4j.api.MergeRequestApi.getDiffs(MergeRequestApi.java:591) at org.gitlab4j.api.MergeRequestApi.getDiffs(MergeRequestApi.java:575) at com.indeed.pqp.service.daemon.util.LanguageHelper.getDiffFilePath(LanguageHelper.kt:25) at com.indeed.pqp.service.daemon.util.LanguageHelperTest.get changed file languages(LanguageHelperTest.kt:18) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

I tried to use Postman to call the API https://code.xxx.com/api/v4/projects/123/merge_requests/1/diffs, and it worked as expected. Can someone help me take a look? Thanks!

sjyzheng avatar Apr 02 '24 16:04 sjyzheng

If the request works with Postman, what you can try to do is to enable logging of HTTP request/response to understand what is going on.

Here is how:

new GitLabApi(..., ....)
            .withRequestResponseLogging(Level.INFO);

This way you might be able to compare with what you are sending from Postman and why the GitLab server answers with 500.

jmini avatar Apr 12 '24 12:04 jmini

If I add itemsPerPage, it doesn't produce 500.

To be precise: org.gitlab4j.api.MergeRequestApi#getDiffs(java.lang.Object, java.lang.Long, int) ,it's ok! But: org.gitlab4j.api.MergeRequestApi#getDiffs(java.lang.Object, java.lang.Long) , Probably because of the default 96, the error is generated? image

After my trial and error, if itemsPerPage is more than 30, it produces error 500. If it is less than or equal to 30, it produces 200.

Hopefully, this result will help fix the error!

iwangjie avatar May 13 '24 02:05 iwangjie