question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BITBUCKET CLOUD] Invalid pagination / missing next

See original GitHub issue

I tried to loop over my workspaces and over the repos to get all pipelines with the following code:

from atlassian.bitbucket.cloud import Cloud
from pprint import pprint

bb = Cloud(
    url="https://api.bitbucket.org",
    username="myusr",
    password="mypass",
)

for x in bb.workspaces.each():
    print(x.name)
    if x.slug == "myworkspace":
        y = x.repositories.get("myrepo")
        print(y.name, y.description)

        pipes = y.pipelines.each()
        for p in pipes:
            print(p.build_number)

It returns the following error

AssertionError: Wrong response for url [https://api.bitbucket.org/2.0/repositories/.../.../pipelines], the size attribute doesn't match the number of recieved values:

JSON Output of the request like this one:

{
    "page": 1,
    "pagelen": 10,
    "values": [....10 pipes here...],
    "size": 21
}

The size option gave me the total number of pipelines (21). But the response only gave me 10 pipes with no next attribute. Therefore an error happend here:

https://github.com/atlassian-api/atlassian-python-api/blob/4066a9e6da06a57fe411fb703c8b0acb17c88be1/atlassian/bitbucket/cloud/base.py#L62

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sti0commented, Dec 20, 2020

Thanks for the quick fix.

Another error occured when calling completed_on @ pipeline level:

return self.get_data("completed_on", "never completed")
TypeError: get_data() takes 2 positional arguments but 3 were given

https://github.com/atlassian-api/atlassian-python-api/blob/c51db61ae02333e9454a0ebdd0923f080be8f890/atlassian/bitbucket/cloud/repositories/pipelines.py#L120

1reaction
Spacetowncommented, Dec 20, 2020

One hint from my site. The workspace is accessed by the slug or the uuid. Therefore changing the code:

for x in bb.workspaces.each():
    print(x.name)
    if x.slug == "myworkspace":

to

x = bb.workspaces.get("myworkspace")

will be faster if you have several workspaces.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Something went wrong Error while fetching
Solved: Hey!! I am trying to fetch all the files from my directory. The curl which I am using is ``` curl -u...
Read more >
bitbucket API 2.0 page parameters using non-default pagelen
ORIGINAL ANSWER: I was able to get around this by creating a bash script that looped through each page of 10 results, adding...
Read more >
Pagination doesn't work with API Version 2.0 Calls - Bitbucket
The fetch all finds the first 10 results and as soon as it attempts the next page call you will get: Resource not...
Read more >
Terraform Cloud API Documentation - HashiCorp Developer
All requests must be authenticated with a bearer token. Use the HTTP header Authorization with the value Bearer <token> . If the token...
Read more >
Two-factor authentication - GitLab Docs
Any existing recovery codes you saved will be invalidated. (yes/no) yes Your two-factor authentication recovery codes are: 119135e5a3ebce8e 11f6v2a498810dcd ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found