Before submitting#
Area#
apps/server
Steps to reproduce#
- Add a project whose
origin is on a self-hosted GitLab with a host name that doesn't contain "gitlab", such as https://code.example.com/group/project.git.
- Sign
glab in to that host with glab auth login --hostname code.example.com.
- Open a thread in that project and open "Link pull request".
- Enter
#1. Plain 1 behaves the same.
Expected behavior#
The dialog resolves #1 to https://code.example.com/group/project/-/merge_requests/1 and links it, the same as on gitlab.com.
Actual behavior#
The dialog says "Paste a full URL; this project's host has no known pull request URL." Pasting the full merge request URL works.
Impact#
Minor bug or occasional failure
Version or commit#
main at 00eb8f6183
Environment#
Linux, desktop and web. glab is signed in to the self-hosted host.
Logs or stack traces#
None. The dialog rejects the input before anything reaches the server.
Cause#
The client builds the merge request URL from the project's repositoryIdentity.provider. That field stays "unknown" when the host name doesn't name a provider, so the client has no URL shape to use.
The server already knows the answer. The Pull Requests page asks gh and glab which one is signed in to the remote's host, and it lists this project's merge requests fine.
The repository identity resolver has a refine step for the same job, in RepositoryIdentityResolverLayerLive in apps/server/src/server.ts. It only ever records Forgejo. It also hands the CLIs a placeholder provider named "Unknown", and GitLab's refinement compares the hosts from glab auth status against that name. So GitLab can never match there.
Workaround#
Paste the full merge request URL.
Fix#
I have a fix ready and can open a PR. It moves the refine step into its own module, passes the remote's real host to the CLIs, and records gitlab on the identity when glab is signed in to that host. It doesn't start any new processes, since the same check already runs for every unknown host. Two tests cover it, and the first fails without the fix.
Note
Grok responding on behalf of Julius.
Triage#
Thanks for the thorough report, @TonybynMp4. Your diagnosis matches what's on
mainat00eb8f6183.What's happening
The dialog never asks the server.
resolveLinkPullRequestInputbuilds the URL withchangeRequestUrlFor(identity.provider, ...), and that returns null forprovider: "unknown", which produces the error you saw.detectSourceControlProviderFromRemoteUrlonly marks a host as GitLab when it'sgitlab.comor has agitlabDNS label, socode.example.comstaysunknown.The Pull requests page already handles this case. It calls
resolveHandlewith a provider built from the remote URL, whose name is the real host, andrefineUnknownGitLabRemotematches that againstglab auth status. That result isn't written back onto the repository identity, though, so the dialog still seesunknown.The
refinecallback inRepositoryIdentityResolverLayerLivecan't record GitLab either:resolveHandlewith{ kind: "unknown", name: "Unknown", baseUrl: "" }. GitLab refinement comparesglabhosts toprovider.name, so it looks for a host namedunknownand never matches.forgejo.Likely fix area#
provider: "gitlab"on the identity whenglabis signed in to that host. That's close to the approach you described, and it reuses the check that already runs for unknown hosts, so it starts no new processes.glabisn't signed in to the host, the dialog should keep refusing bare numbers. Pasting a full merge request URL should keep working.glabis signed in to is stored asgitlab.githubin the name, are a separate case.A maintainer will decide on the fix direction.