| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Looks like a regression from ac1c619, as we started deleting kwargs for other reasons, so by the time we're doing do_list() in the CLI the user_id is already gone.
It's interesting that there's no issue with API, only with CLI.
Below code
user = gl.users.get(3) print(user.projects.list())
gets and prints the project list without any issue.
@w7089 it's mostly because of how the CLI constructs the methods called. Some arguments get passed around in run() and get cleaned up erroneously in this case because we use a custom method that expects the arguments used a little differently from our normal mixins.
If it's acceptable, i'll open a PR after testing of other managers.
Please feel free to open a PR if you think you have a valid fix. Thanks.
I think the main reason for this is because of UserProjectManager and the fact that the path has to be regenerated.
python-gitlab/gitlab/v4/objects/users.py
Lines 575 to 641 in 86eba06
| class UserProjectManager(ListMixin, CreateMixin, RESTManager): | |
| _path = "/projects/user/{user_id}" | |
| _obj_cls = UserProject | |
| _from_parent_attrs = {"user_id": "id"} | |
| _create_attrs = RequiredOptional( | |
| required=("name",), | |
| optional=( | |
| "default_branch", | |
| "issues_enabled", | |
| "wall_enabled", | |
| "merge_requests_enabled", | |
| "wiki_enabled", | |
| "snippets_enabled", | |
| "squash_option", | |
| "public", | |
| "visibility", | |
| "description", | |
| "builds_enabled", | |
| "public_builds", | |
| "import_url", | |
| "only_allow_merge_if_build_succeeds", | |
| ), | |
| ) | |
| _list_filters = ( | |
| "archived", | |
| "visibility", | |
| "order_by", | |
| "sort", | |
| "search", | |
| "simple", | |
| "owned", | |
| "membership", | |
| "starred", | |
| "statistics", | |
| "with_issues_enabled", | |
| "with_merge_requests_enabled", | |
| "with_custom_attributes", | |
| "with_programming_language", | |
| "wiki_checksum_failed", | |
| "repository_checksum_failed", | |
| "min_access_level", | |
| "id_after", | |
| "id_before", | |
| ) | |
| def list(self, **kwargs: Any) -> Union[RESTObjectList, List[RESTObject]]: | |
| """Retrieve a list of objects. | |
| Args: | |
| all: If True, return all the items, without pagination | |
| per_page: Number of items to retrieve per request | |
| page: ID of the page to return (starts with page 1) | |
| iterator: If set to True and no pagination option is | |
| defined, return a generator instead of a list | |
| **kwargs: Extra options to send to the server (e.g. sudo) | |
| Returns: | |
| The list of objects, or a generator if `iterator` is True | |
| Raises: | |
| GitlabAuthenticationError: If authentication is not correct | |
| GitlabListError: If the server cannot perform the request | |
| """ | |
| if self._parent: | |
| path = f"/users/{self._parent.id}/projects" | |
| else: | |
| path = f"/users/{kwargs['user_id']}/projects" |
So maybe the idea of setting the parent attributes is correct but I'm not sure.
ok, opened the pull request, 2 previous PRs can be deleted, they are not relevant.
@JohnVillalovos any feedback on the PR?
@JohnVillalovos any feedback on the PR?
I'll try to look at it this week. Sorry for the delay.
| Back | FazBrowse Home | New Git URL |
Description of the problem, including code/CLI snippet
gitlab user-project list --user-id 42 fails.
A similar issue has previously been reported in #881 .
Expected Behavior
List of projects owned by the current user are shown.
Actual Behavior
Impossible to list objects ('user_id') is printed.
Specifications
Notes
So I solved my particular problem by hard-coding my user-id in gitlab/v4/objects/user.py l. 641 (in the UserProjectManager list method). Obviously not a general solution, but maybe it helps to track down the error or someone else who comes across this. :)
Furthermore, what I really don't understand is why no KeyError is raised when the format string is processed.