Unable to purchase CI minutes from within subgroups or its descendants
Summary
Users are redirected to the 404 page when they click on Buy additional minutes
while in a subgroup or a project within a subgroup. This issue affects the purchase button located in the Out of minutes notification (::Ci::Minutes::Notification
).
Steps to reproduce
- Create a group, subgroups, and projects in the subgroup
- Trigger pipelines in the projects to consume at least 70% of the quota in your group
- If you have admin access, you can edit the group and reduce the quota
- Navigate to either:
- The main page of project in the subgroup
- Or the CI/CD -> Pipelines page of project in the subgroup
- Click "Buy more Pipeline minutes"
- Greeted by 404
Example Project
https://gitlab.com/m8290/ci-usage/subci/subci-proj
What is the current bug behavior?
The owner of a group is redirected to a 404 page because the URL (https://gitlab.com/-/subscriptions/buy_minutes?selected_group=******
) uses the subgroupID instead of the top-level groupID
What is the expected correct behavior?
&5391 (closed) should load and allow for a purchase
Possible fixes
The 404 error is because:
- We search for the top-level groups ONLY that the user has access to:
selected_group=current_user.manageable_groups.top_most.find(params[:selected_group])
- If it is a subgroup, the resulting group object will be nil
- And we return 404 if group is nil
The possible fix would be to:
- Get the top level group's ID
- Redirect to the purchase URL https://gitlab.com/-/subscriptions/buy_minutes with
selected_group
set to the top level group ID
Edited by Firdaws Farukh