Skip to content

fix(gitlab): reads reach a self-managed GitLab served on a custom port - #40333

Closed
ahmedisam99 wants to merge 1 commit into
pingdotgg:mainfrom
ahmedisam99:fix/gitlab-custom-port-host
Closed

ahmedisam99 wants to merge 1 commit into
pingdotgg:mainfrom
ahmedisam99:fix/gitlab-custom-port-host

Conversation

@ahmedisam99

Copy link
Copy Markdown

Problem

On a self-managed GitLab served on a custom port (origin http://10.129.10.143:9999/group/project.git), every merge request read fails, so PR watches never wake and merged threads never auto-settle (#40306). Repository keys drop the port, and GitLabCli passes that port-less host to glab as GITLAB_HOST, so glab calls https://10.129.10.143:443 and gets connection refused.

Change

GitLabCli now checks a host that has no port against the checkout glab runs in. When exactly one HTTP(S) remote of that checkout has the same hostname with an explicit port, glab gets that host:port. In every other case the host is passed as before:

  • SSH remotes don't count: their port belongs to the SSH server, not the web API. This is the same rule isChangeRequestAuthorityOfProject uses.
  • Remotes on two ports for one hostname leave the host as given.
  • A host that already names a port skips the lookup.
  • If the remotes can't be listed, the host is used as given.

Each checkout's remotes are cached for a minute, so the watch and sync sweeps don't start git before every glab call. Repository keys and stored links keep their port-less hosts; only the host handed to glab changes.

Scope

Fixes #40306: every merge request read fails on a GitLab served on a custom port.

Verification

  • Found on a t3 serve 0.1.11 server whose GitLab is served over HTTP on port 9999. Every PullRequestWatchReactor and PullRequestSyncReactor read of the MR failed with "GitLab CLI command failed", and the link kept snapshot: null. I reran the failing glab api projects/<path>/merge_requests/<n> by hand. With GITLAB_HOST=10.129.10.143 it failed with connection refused on port 443. With GITLAB_HOST=10.129.10.143:9999 it returned the merged MR.
  • New GitLabCli.test.ts cases check that:
    • an HTTP remote's port is used;
    • an SSH remote's port, a remote with no port, a remote on another host, and remotes on two ports leave the host as given;
    • a host that names a port skips the lookup;
    • a failed remote listing keeps the host;
    • consecutive commands list the remotes once.
  • vp run test in packages/source-control-gitlab: all 303 tests pass. vp run check:changed: format, lint, knip, typecheck of 11 packages, and tests all pass.
  • Not checked: a server built from this branch, end to end against that GitLab.

🤖 Generated with Claude Code using Claude Opus 5.5.

Repository keys drop the port, so a merge request on a GitLab served at
http://host:9999 was read with GITLAB_HOST=host, which glab sends to
https://host:443. A host without a port is now spelled as the checkout's
one HTTP remote on that host spells it.

Fixes pingdotgg#40306

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 21, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #40321 makes the same change and is the one being kept.

#40321 addresses the same dropped-port failure using the project's already-resolved HTTP remote. That keeps the fix smaller and avoids another Git lookup and a separate cache.

Your diagnosis also establishes why this breaks merged-thread settlement: the failed reads leave the linked merge request without a current snapshot. That evidence remains useful for validating the shared fix.

Closing as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab PR watches never read merge requests on a self-managed GitLab served on a custom port

2 participants