403 when trying to create an MR
Description
Expected Behavior vs Actual Behavior No 403, successfully created an MR.
Possible Fix
Steps to Reproduce
Logs
@bq:16:38:51:/media/d/temp/git/slidge$ glab mr create
? Choose a template Open a blank merge request
? Title: Return an error when trying to chat with transport
? Description <Received>
? What's next? Submit
Creating merge request for groupchat_join_keyerror into in bodqhrohro/slidge
POST https://gitlab.com/api/v4/projects/nicocool84/slidge/merge_requests: 403 {message: 403 Forbidden}
Your Environment
- Version used (Run
glab --version):glab version DEV(installed from Nix asglab-1.18.1) - Operating System and version: Debian 11
Hi @bodqhrohro. Have you authenticated against GitLab using glab auth login?
AFAIR, yes; at least, there is an entry with user/token in config.yml.
I noticed though that there is !!null before the token; is it how it should be?
What's the output when you run glab auth status?
@bq:18:26:40:/media/d/temp/git/slidge$ glab auth status
gitlab.com
✓ Logged in to gitlab.com as bodqhrohro (/home/bodqhrohro/.config/glab-cli/config.yml)
✓ Git operations for gitlab.com configured to use https protocol.
✓ API calls for gitlab.com are made over https protocol
✓ REST API Endpoint: https://gitlab.com/api/v4/
✓ GraphQL Endpoint: https://gitlab.com/api/graphql/
✓ Token: ********************
Mostly you get 403 error when
-
MRs are disabled on the repository.
When merge requests are disabled on a repository, GitLab only returns error 403 (unauthorised) so it's difficult to print out the right error message unless we query the projects api and check if merge requests are disabled (which is another issue to work on).
-
Token does not have enough permissions to manage merge requests.
The minimum required scopes are
apiandwrite_repository.
Neither.
I found the source of the problem: glab tried to create the MR in the fork repository rather than in the parent repository.
It remembered the chosen repository once and does not ask me anymore. gh asks every time as a first stage what repository I want to create a PR/issue in, why doesn't glab do? I have to specify it explicitly via the -R key now, which is also not explicitly stated in glab --help, so I could only guess it from the previous experience with gh or from examples.
glab saves the selected base repository in the local git config in the format remote.<remote-name>.glab-resolved.
You can unset it with:
git config --unset remote.<remote-name>.glab-resolved
After unsetting it, glab should prompt for the base repository when run or you can manually set it with:
git config --add remote.<remote-name>.glab-resolved base
NB: substitute <remote-name> for the name of the remote containing the base repo
@bodqhrohro, just to bring to your notice, you're running a much older version of glab btw
Okay, upgraded to 1.20.0.
Still does not ask for the base repository until explicitly reset.
This issue has been automatically marked as stale because it has not had recent activity. We haven't had the time to address it yet, but we want to keep it open. This message is just a reminder for us to help triage issues.
This issue has been automatically marked as stale because it has not had recent activity. We haven't had the time to address it yet, but we want to keep it open. This message is just a reminder for us to help triage issues.