atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

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

Open sbgamma opened this issue 1 year ago • 1 comments

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 avatar Jan 31 '24 12:01 sbgamma

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/"
    ]
  }
}

sbgamma avatar Jan 31 '24 12:01 sbgamma