glab-resolved fails with gitlab hosted in subdir of domain

Checklist

  • I'm using the latest version of the extension (Run glab --version)
    • Extension version: glab version 1.24.1 (2022-12-07)
  • Operating System and version: win11

Summary

I have a self-managed gitlab instance (in a docker swarm) in a subdirectory, as in https://my.host.com/git/. Similar to #1046 (closed) (Can't use glab with private/hosted gitlab instances), it seems that the subdir component is being copied into the API url.

Edit for findability: relative URL.

Steps to reproduce

My ~/.config/glab-cli/config.yml entry:

hosts:
    my.host.com:
        git_protocol: ssh
        api_host: my.host.com/git
        api_protocol: https
        token: *************************

The basic connection works,

$ glab auth status
my.host.com
  ✓ Logged in to my.host.com as my.user (C:\Users\r2\.config\glab-cli/config.yml)
  ✓ Git operations for my.host.com configured to use ssh protocol.
  ✓ API calls for my.host.com are made over https protocol
  ✓ REST API Endpoint: https://my.host.com/api/v4/
  ✓ GraphQL Endpoint: https://my.host.com/api/graphql/
  ✓ Token: **************************

Side note: that's listing my.host.com/api/.. as successful, but it is really querying my.host.com/git/api/... Perhaps that should check/use the api_host from the config.yml?

What is the current bug behavior?

In a repo directory:

$ glab issue list
GET https://my.host.com/git/api/v4/projects/git/GROUPNAME/PROJECTNAME/issues: 404 {message: 404 Project Not Found}

What is the expected correct behavior?

Returns the list of issues.

Relevant logs and/or screenshots

In the gitlab instance, the logs include

gitlab_1         | ==> /var/log/gitlab/gitlab-rails/production.log <==
gitlab_1         | Started GET "/git/api/v4/projects/git%2FGROUPNAME%2FPROJECTNAME/issues?in=title%2Cdescription&page=1&per_page=30&state=opened" for 11.22.33.44 at 2022-12-22 18:27:55 +0000

In the ./.git/config,

[remote "origin"]
        url = ssh://git@my.host.com:60022/GROUPNAME/PROJECTNAME.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        glab-resolved = base:git/GROUPNAME/PROJECTNAME

It looks as if the base:git/... should be changed to base:....

Possible fixes

I manually edited the remote to:

[remote "origin"]
        url = ssh://git@my.host.com:60022/GROUPNAME/PROJECTNAME.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        glab-resolved = base:GROUPNAME/PROJECTNAME

and now this works,

$ glab issue list
Showing 8 open issues in GROUPNAME/PROJECTNAME that match your search (Page 1)

#26  GROUPNAME/PROJECTNAME#26  migrate database-connecting functions to support datamart                                about 11 days ago
...
Edited Mar 04, 2024 by Katrin Leinweber
Assignee Loading
Time tracking Loading