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

Support GitLab groups/subgroups when querying API for projects/issues #2529

Open
Nezteb opened this issue Mar 22, 2023 · 9 comments
Open

Support GitLab groups/subgroups when querying API for projects/issues #2529

Nezteb opened this issue Mar 22, 2023 · 9 comments

Comments

@Nezteb
Copy link

Nezteb commented Mar 22, 2023

Problem Statement

I'm trying to set up the GitLab.com integration, and my current settings aren't working no matter what values I use. In this case, my company's GitLab org (we'll call it company) has a backend-team subgroup.
Screenshot 2023-03-21 at 10 57 46 PM

❔ Possible Solution

Regardless of what "source" I set, the app tries to call the /projects/<group>/issues endpoint. From what I can tell, the official GitLab API docs don't mention that specific endpoint: https://docs.gitlab.com/ee/api/rest/index.html

If you instead use the /groups/<group>%2<subgroup>/projects (the %2 is important) endpoint to get a list of projects and then iterate over that list of project IDs, you could get the issues from the /projects/<id>/issues endpoint.

⤴️ Describe alternatives you've considered

I've also tried just using the top-level group for the company, but that doesn't seem to work either.

➕ Additional context

Relevant existing/closed issues and PRs:

@github-actions
Copy link

Thank you very much for opening up this issue! I am currently a bit overwhelmed by the many requests that arrive each week, so please forgive me, if I fail to respond personally. I am still very likely to at least skim read your request and I'll probably try to fix all (real) bugs if possible and I will likely review every single PR being made (please, give me a heads up if you intent to do so) and I will try to work on popular requests (please upvote via thumbs up on the original issue) whenever possible, but trying to respond to every single issue over the last years has been kind of draining and I need to adjust my approach for this project to remain fun for me and to make any progress with actually coding new stuff. Thanks for your understanding!

@Blackclaws
Copy link

Blackclaws commented Mar 29, 2023

You need to either put a group path at the top and select: "Group" as source

Or you need to put a project path and select "Project" as source.

Both work fine for me even for subgroups.

You need to paste the full group/project path too, so if you have a company group called:

CompanyA

with a subgroup Teams you need to put

CompanyA/Teams/BackendTeam

Let me know if you have further issues.

Edit: It might be that subgroup sources don't work correctly after all, I apparently was trying with project in subgroup which works fine. Standard group sources and project sources work fine though.

@Nezteb
Copy link
Author

Nezteb commented Mar 29, 2023

Attempting this again:

Subgroup

Top-level group

Project

If I repeat all of these same but for a specific repo, say https://gitlab.com/company/mobile-app, everything works, because it's using the /projects endpoint.

Summary

So, I think pulling issues for an entire group is broken. There is code for handling groups, but it doesn't seem to be working:

if (project || projectConfig.source === 'project') {
apiURL += 'projects/' + projectURL;
} else if (projectConfig.source === 'group') {
apiURL += 'groups/' + projectURL;
}

@github-actions
Copy link

This issue has not received any updates in 90 days. Please comment, if this still relevant!

@github-actions github-actions bot added the Stale label Jul 28, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2023
@excalios
Copy link

excalios commented Jul 9, 2024

This issue is still relevant when getting notes or the issue detail itself is still giving an error. I would love it if anyone could help with this issue or give hints. Personally, this is very disturbing. Since, sometimes not all of my issue is loaded and even if it does it always shows an error popup.

When trying to get issues by its iids it will be an error since it will hit projects/{PROJECT} meanwhile {PROJECT} is set based on group or even username when set into GROUP or ALL. When getting issue details it has the same behavior.

I'm currently trying to understand the codebase and the GitLab API itself. So far what I got is:

Getting by iids

GROUP

When getting by iids it should still hit the groups endpoint but it currently hits the projects endpoint since we passed projects arguments from the GitLab config. Which is the group name, not the project name. I tried to fix it by changing the _apiLink function inside gitlab_api.service.ts specifically this part:

    if (
      (project !== projectConfig.project && projectConfig.project !== 'group') ||
      projectConfig.source === 'project'
    ) {
      apiURL += 'projects/' + projectURL;
    } else if (projectConfig.source === 'group') {
      apiURL += 'groups/' + projectURL;
    }

I checked whether the project that is passed is the same as the config and if it's not group it goes to group. Changing it into a switch and handling it inside switch case might be better.

ALL

I haven't checked this but with the fix above it will try to hit projects with our username that is set

Get issue detail

The issue is the same as it doesn't hit the proper projects, I tried to get from single issues endpoint but it's administrator only. I'm thinking it should pass the proper project id so the getProject function can return the project id for that specific issue. But, I haven't been able to find the specific part of the code that handles this logic.

@excalios
Copy link

excalios commented Jul 9, 2024

is it possible to open this issue since it's still relevant? @johannesjo

@johannesjo johannesjo reopened this Jul 10, 2024
@johannesjo johannesjo removed the Stale label Jul 10, 2024
@kronehero
Copy link

In version 10.0.11 on Windows 11, I can successfully access the issues for all group projects using the GitLab integration. I still can't use it because on the second automatic pull all issues are added again, so I get duplicates of issues I already have in my list. This doesn't happen if I use "Project" as source instead of "Group" in the integration settings.

In my eyes this problem is part of the GitHub issue and I just want to mention it here. Please let me know if it's not a problem at all and can be fixed by changing the configuration.

This is what my GitLab integration setup looks like:

@cbergmann
Copy link
Contributor

Hi, after some month I tried the gitlab integration again. I found out that currently the "source" option is no longer available. I still have the requirement to search for issues on a group or instance level. Adding multiple Providers is not a option because there are many projects and they also change often.

I therefore propose the following change:

  1. add a new Option for the gitlab issue provider "search scope" which has the options "project", "group", "instance".
  2. The default for existing and new configurations is "project". This does not change the current function.
  3. Depending on the selected option the search requests use the "/projects/:id/issues", "/groups/:id/issues" or "/issues" endpoint respectively.
  4. For the ':id' in the "/groups/:id/issues" endpoint the "user name/project" config option is split by "/" and all but the last parts are used as ':id'.
  5. Create and update requests always use the respective "/projects/:id/issues" endpoints.

I will look into this in the next days and see if I can create a small merge request. Any hints or improvements on this proposal are welcome. I have not looked into the datamodel if we need to change it to save the project of the issues to make the requests for "/projects/:id/issues/:id" etc. possible in this scheme as we could have issues from multiple project when searching for "group" or "instance" issues. Tips on this are also very welcome.

Kind regards
Clemens

@cbergmann
Copy link
Contributor

Hi, this would be my proposal for the instance/group issue search feature: !3901

While testing I found that the submission of spent time seems to not be working also. I might look into this if I could find time.

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

No branches or pull requests

6 participants