Getting 500 Internal Server Error when trying to push changes using Bitbucket APIs
Asked by anubhav vats:

Sometimes while using this API <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/src#post>  

I am getting a response with a 500 status code. The response body does not contain enough information to debug it. Please help me in this regard.


Answers:
author: Theodora Boudale
body: Hi [@anubhav vats](/t5/user/viewprofilepage/user-id/4418633) and welcome to the community

**1.** Could you please copy-paste the full response you get (omitting sensitive info, if any)? Usually, in responses with 500 error there is an id included, which I could look up in our system for further info.

**2.** If you are able to reproduce this, could you check how much time it takes from the moment you execute the API call, until you get this response? One possibility is that the request may be timing out.

**3.** What is the approximate number of files and their size you are trying to commit/push with this endpoint, when you get these errors?

**4.** Since you mention "sometimes", I assume that the issue doesn't occur every time you use this endpoint, and it did not happen only once, but there were a few times that this happened, when you were trying to create different commits? (Just trying to understand the scope of the issue)

Kind regards,  
Theodora

comments: author: anubhav vats
body: Thanks, [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) for looking into this issue.

```

1.?{
     type: 'error',
     error: {
       message: 'Something went wrong',
       id: '96eb231e4d684d8c978d4c0aa663bdf1'
      }
    }
I am getting this response. Please debug on your system why this is happening.
```

2. I reproduced the error and found it takes about 1696.595 ms to get a response with status code 500.  

3. I am just trying to push change for one single file with a size of 2.3 KB.  

4. Yes you are understanding the issue correctly. I also want to add that I get 500 for the same repository every time and I have read, write and admin access to that repo.   


author: Theodora Boudale
body: Hi [@anubhav vats](/t5/user/viewprofilepage/user-id/4418633) ,

Thank you for the info.

I checked this error code in our system, and I see the error message:

```
pre-receive hook exited with 1

One of your commit messages is missing a valid issue key:
```

After that, a specific commit with its commit message is displayed, but I have omitted it because I am unsure if you'd like me to post it here.

Based on the error message, it looks that the option "**Require issue keys in commit messages** " may be enabled for this repository. This is possible if you have linked with JIRA or with another external application. You can double check that if you go to **Repository settings** \> **Links** , is the option "**Require issue keys in commit messages**" enabled for the repo you are trying to push?

If so, you'll need to include a valid issue key in the commit message for the call to succeed.

One example:
> curl -X POST -u username:app-password [https://api.bitbucket.org/2.0/repositories/\<workspace-id\>/\<repo-slug\>/src](https://api.bitbucket.org/2.0/repositories/<workspace-id>/<repo-slug>/src) -F File2.json=@File1.json -F branch=test-branch -F message="my commit message TEST-123"

Where TEST-123 replace with a valid issue key for your case.

Is this something that works for you?

Please feel free to let me know how it goes and if you need any further help.

Kind regards,  
Theodora


author: anubhav vats
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) Thanks a lot man!!! Because of your help, I was able to complete my work. Great thanks to you.  


author: Theodora Boudale
body: [@anubhav vats](/t5/user/viewprofilepage/user-id/4418633) , you are very welcome! I'm glad to have helped and that the issue is resolved.

Please feel free to reach out if you ever need anything else!

Have a nice day,  
Theodora


Tags: bitbucket-cloud

cloud

error