woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.17k stars 360 forks source link

When activating a Bitbucket repo, server requests for branches endlessly #2506

Closed mzampetakis closed 1 year ago

mzampetakis commented 1 year ago

Component

server

Describe the bug

As soon as I activate a repo from bitbucket forge through UI, It sends multiple request to fetch the repo's branches for different pages. So we have consecutive requests with page incrementing by 1 after each call:

/api/repos/5/branches?page=1
/api/repos/5/branches?page=2
/api/repos/5/branches?page=3
/api/repos/5/branches?page=4
/api/repos/5/branches?page=5
/api/repos/5/branches?page=6
...

All of then result in http 200 but with the exact same result:

["master"]

It seems that UI expects to receive an empty response ([]) in order to stop invoking for the next page.

System Info

Local environment from main (commit: #0eacbe8a33823b75e1ecdd738f6c0cad00bd7d68)

The output of `/version` is:

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"dev"}

### Additional context

Tested using other forges (Github & Gitlab) and the issue does not occurs.

![Screenshot 2023-09-27 at 21 55 51](https://github.com/woodpecker-ci/woodpecker/assets/16765483/0a1f929d-4887-470f-a10c-414662341360)

The same log is repeated over and over agian:

9:54PM DBG server/router/middleware/logger.go:59 > ip=XXX latency=287.846458 method=GET path=/api/repos/5/branches status=200 user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"



### Validations

- [X] Read the [Contributing Guidelines](https://github.com/woodpecker-ci/woodpecker/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://woodpecker-ci.org/docs/intro).
- [X] Check that there isn't [already an issue](https://github.com/woodpecker-ci/woodpecker/issues) that reports the same bug to avoid creating a duplicate.
- [X] Checked that the bug isn't fixed in the `next` version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
- [X] Check that this is a concrete bug. For Q&A join our [Discord Chat Server](https://discord.gg/fcMQqSMXJy) or the [Matrix room](https://matrix.to/#/#woodpecker:matrix.org).
qwerty287 commented 1 year ago

Looks like pagination done wrong. Do you know how you can paginate in bitbucket?

mzampetakis commented 1 year ago

Indeed. It seems that the specific request is missing the pagination parameters. I have paginated other requests towards bitbucket, so I will find that out and open a PR when possible.