Skip to content

[Bug]: Bare pull request numbers can't be linked on a self-hosted GitLab whose host name doesn't say "gitlab" #15390

Description

@TonybynMp4

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. 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.
  2. Sign glab in to that host with glab auth login --hostname code.example.com.
  3. Open a thread in that project and open "Link pull request".
  4. 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 00eb8f6

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.

Activity

  1. juliusmarminge commented on Oct 3, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Triage

    Thanks for the thorough report, @TonybynMp4. Your diagnosis matches what's on main at 00eb8f6183.

    What's happening

    The dialog never asks the server. resolveLinkPullRequestInput builds the URL with changeRequestUrlFor(identity.provider, ...), and that returns null for provider: "unknown", which produces the error you saw. detectSourceControlProviderFromRemoteUrl only marks a host as GitLab when it's gitlab.com or has a gitlab DNS label, so code.example.com stays unknown.

    The Pull requests page already handles this case. It calls resolveHandle with a provider built from the remote URL, whose name is the real host, and refineUnknownGitLabRemote matches that against glab auth status. That result isn't written back onto the repository identity, though, so the dialog still sees unknown.

    The refine callback in RepositoryIdentityResolverLayerLive can't record GitLab either:

    1. It calls resolveHandle with { kind: "unknown", name: "Unknown", baseUrl: "" }. GitLab refinement compares glab hosts to provider.name, so it looks for a host named unknown and never matches.
    2. It keeps the original identity unless the refined kind is forgejo.

    Likely fix area

    • The narrowest option is to pass the existing refinement the remote's real host instead of the placeholder, and keep provider: "gitlab" on the identity when glab is 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.
    • Some things should probably stay as they are. Hostname-based detection can stay unchanged, unrecognized hosts shouldn't be assumed to be GitLab, and when glab isn't signed in to the host, the dialog should keep refusing bare numbers. Pasting a full merge request URL should keep working.
    • A useful test would fail while the placeholder host or the Forgejo-only write is still in place, and pass once a host glab is signed in to is stored as gitlab.
    • Other forges whose host names don't match their provider, such as a GitHub Enterprise host without github in the name, are a separate case.

    A maintainer will decide on the fix direction.

  2. added
    bugSomething is broken or behaving incorrectly.
    via-triageFiled through npx t3 triage
    on Oct 3, 2026
  3. added 3 commits that reference this issue on Oct 3, 2026
    84eedb6
    a596ad0
    057a7db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions