Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs call of commit causes wrong warning #2799

Open
cweber-dbs opened this issue Feb 15, 2024 · 5 comments
Open

refs call of commit causes wrong warning #2799

cweber-dbs opened this issue Feb 15, 2024 · 5 comments

Comments

@cweber-dbs
Copy link

Description of the problem, including code/CLI snippet

Fetching the refs for a commit causes a warning. The warning is missleading due to the fact, that it provides some information for the list() method.

    def _fetch_commit_tag(self, commit: ProjectCommit) -> str:
        tags = commit.refs(type="tag")

Expected Behavior

The warning should inform about the refs() method and not the list() method.

Actual Behavior

The following warning is shown:

UserWarning: Calling a list() method without specifying get_all=True or iterator=True will return a maximum of 20 items. Your query returned 20 of xxx items. See https://python-gitlab.readthedocs.io/en/v4.4.0/api-usage.html#pagination for more details. If this was done intentionally, then this warning can be supressed by adding the argumentget_all=Falseto thelist()call.

Specifications

python-gitlab version: 4.4.0
API version you are using (v3/v4): ?
Gitlab server version (or gitlab.com): v16.8.1-ee

@cweber-dbs
Copy link
Author

Using tags = commit.refs("tag", get_all=True) works fine.

The documentation is misleading as well due to the fact, that only the first 20 matches are returned.
image

@nejch
Copy link
Member

nejch commented Feb 15, 2024

Using tags = commit.refs("tag", get_all=True) works fine.

The documentation is misleading as well due to the fact, that only the first 20 matches are returned.

@cweber-dbs this documentation refers to all types of references (both tags and branches), not necessarily all pages returned by the API, which is covered by the pagination docs. But this is also why we have this runtime warning as it's often confusing in other endpoints.

@JohnVillalovos I guess we could tweak this a bit to also supply the calling method instead if it calls http_list internally, but sometimes I would almost prefer the interface on this to use a manager like we do with most endpoints, so people would call commit.refs.list(). WDYT?

@JohnVillalovos
Copy link
Member

Not an answer to this. Did the warning not indicate the file and line number in the user code that caused the warning? I thought it was supposed to do that.

@cweber-dbs
Copy link
Author

Nope, only the reference to utils.py line 199 is included:

/opt/homebrew/lib/python3.10/site-packages/gitlab/utils.py:199: UserWarning: Calling a `list()` method without specifying `get_all=True` or `iterator=True` will return a maximum of 20 items. Your query returned 20 of 246 items. See https://python-gitlab.readthedocs.io/en/v4.4.0/api-usage.html#pagination for more details. If this was done intentionally, then this warning can be supressed by adding the argument `get_all=False` to the `list()` call.

@JohnVillalovos
Copy link
Member

Not sure if you are able to do it or not, but would be interesting if you could apply the small change to utils.py from #2802

Hopefully the error message would then include the path to the calling code. Though I am surprised and confused that there is no filename at all at the end. I wonder if that could be because it is running on MacOS, which I'm guessing from seeing "homebrew"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants