How to debug Internal server error when performing commit using REST API?
Asked by Anoop Pavuluri:

Hello experts,

I am trying to do a commit using the Bitbucket cloud rest api v2.0, but get an HTTP 500 error. The error response does not have enough information in it to investigate further as it just says 'Something went wrong' with a HTTP 500 (Internal server Error).

I have seen some posts in the community that mentioned a similar issue, and were able to get some insights by the message id. Hence I have pasted the id for reference.

I have read, write, and admin access to the repository and able to do a commit manually.

![Bitbucket Internal Server Error.png](/t5/image/serverpage/image-id/284653iF7A7E0C21410F1EE/image-size/large?v=v2&px=999 "Bitbucket Internal Server Error.png")

Additionally,

1. Is there is a memory limit to each commit that needs to be taken care of?

2. Is there a way for external users to investigate the detail logs using the id?

Any advice on how to overcome this error would be really helpful. Thanks in advance.


Answers:
author: Ben
body: Hi Anoop,

Unfortunately, as 5xx errors refer to internal errors on our side - we generally do not share detailed logging information with users as it may contain sensitive code related to our backend processes. The error code that is returned by the API endpoint is something that we can use to investigate in our backend.

From what I can see on our end, the request timed out and this is why you received this particular error message. Whilst we do not have specific limitations set for commit filesize, there is a 30-second request timeout limit so if the commit process takes longer than this - the API request will fail.

For future reference, when running cURL commands, you can enable some cURL-specific debugging flags that may reveal more about the nature of the error:

```
- curl -s --fail --show-error?-X POST commandgoeshere
```

Hope this helps, please let me know if further clarification is needed.

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Anoop Pavuluri
body: Hi [@Ben](/t5/user/viewprofilepage/user-id/4537226)

Thank you for replying. I understand that the logs are not accessible to external users.

I have been trying different things but still encounter the error almost every time I do a commit(9 out of 10 times). Also, I captured the time taken for execution by the API and observed that its less than 30 seconds per commit, but I still get the same error.

![Screenshot 2023-10-06 160154.png](https://community.atlassian.com/t5/image/serverpage/image-id/284959iAE96098ADD981E5C/image-dimensions/462x64?v=v2 "Screenshot 2023-10-06 160154.png")

I am trying to call the API as suggested in this link:

<https://www.npmjs.com/package/bitbucket>

![Screenshot 2023-10-06 152747.png](https://community.atlassian.com/t5/image/serverpage/image-id/284957i5AB19BC90EC93DDF/image-dimensions/459x551?v=v2 "Screenshot 2023-10-06 152747.png")

The restForm object contains data in the 'multipart/form-data' format and also I have declared all the params correctly as per the recommendation.


author: Ben
body: Hi Anoop,

The only official documentation we have available for creating a commit is by uploading a file to the repository source using the /2.0/repositories API endpoint (which, in turn - will create a commit):

* <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source#api-repositories-workspace-repo-slug-src-post>

I have tested this endpoint by uploading files to my repository and I can confirm that it functions as expected by following this documentation and using cURL commands to POST this data to the repository.

The documentation that you have provided suggests the use of a third-party script, unfortunately, I am unable to troubleshoot this as it falls outside of our [support scope](https://confluence.atlassian.com/support/atlassian-support-offerings-193299636.html). I would suggest reaching out to the NPMJS community forums below if you intend to use this script:

* <https://www.npmjs.com/support>

Cheers!

- Ben (Bitbucket Cloud Support)


author: Anoop Pavuluri
body: Thanks Ben!


author: Anoop Pavuluri
body: Dear [@Ben](/t5/user/viewprofilepage/user-id/4537226)

Unfortunately, it still did not work. I tried by implementing the way as suggested by the official API(the node.js example), but still get a HTTP 500 Internal server error.

I logged the execution time in the handler but it always was less than 30 seconds, so I don't think timeout is the issue here. Could you get more information regarding the error from the log IDs below?

![something went wrong1.png](https://community.atlassian.com/t5/image/serverpage/image-id/285419i79D8E3B39B3B6BE4/image-size/large?v=v2&px=999 "something went wrong1.png") ![something went wrong.png](https://community.atlassian.com/t5/image/serverpage/image-id/285409i84BB0FFBD9CF72D6/image-size/large?v=v2&px=999 "something went wrong.png")

**Note**: In my actual code, the params const is filled with data before performing the POST. Screenshot simplified just for example.

![bitbucket error 500.png](https://community.atlassian.com/t5/image/serverpage/image-id/285408i85A3C7E261B3D811/image-size/large?v=v2&px=999 "bitbucket error 500.png")


author: Ben
body: Hey Anoop,

Our backend still reports the same (RequestTimeoutError) however I note that you are performing these queries against a paid workspace. I was not aware of this initially as the email you have used to log this ticket is not linked to such a workspace, my apologies.

As a result of this, I will be raising a support ticket on your behalf and investigating this further - as you have an entitlement to Standard-level support.

We will need your exact commands and further information that would not be appropriate to share on a public forum, so I believe a support ticket is the best course of action here to work towards a solution.

Please check the email address that is associated with the paid workspace that you are querying to access the support ticket.

Cheers!

- Ben (Bitbucket Cloud Support)


Tags: bitbucket-cloud

cloud

rest-api