atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.29k stars 642 forks source link

Bitbucket cloud - Commits.each() - trailing / included incorrectly when top param is set #1319

Open sbgamma opened 5 months ago

sbgamma commented 5 months ago

https://github.com/atlassian-api/atlassian-python-api/blob/ac0e1fe3fa612941a383e51ab527d95236108232/atlassian/bitbucket/cloud/repositories/commits.py#L37-L38

A trailing slash is always added to the URL in requests for this endpoint.

If the "top" param is set, then the resulting URL will be https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commits/{commit}/. This results in a 404.

I'll raise a PR to fix this.

sbgamma commented 5 months ago

To clarify, the Bitbucket API is interpreting the / as part of the commit hash. Sample response shown below:

{
  "type": "error",
  "error": {
    "message": "Commit not found",
    "data": {
      "shas": [
        "05XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX03/"
      ]
    }
  },
  "data": {
    "shas": [
      "05XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX03/"
    ]
  }
}