Skip to content

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

Open

Description

@ahmedisam99

What happened

An agent opened a merge request on our self-managed GitLab and started a PR watch until it merged. The pipeline passed and I merged the MR, but the watch never woke the agent. It kept waiting until I told it myself that the checks had passed and the MR was merged.

Diagnosis

The watch never managed to read the merge request: the host it hands to glab has lost the GitLab server's port.

  1. The PR link stores the host without its port. The checkout's origin is http://10.129.10.143:9999/group/project.git. The thread's PR link gets its host from changeRequestHost (linkCreatedPullRequest.ts#L39) and is stored as host: "10.129.10.143", while its url keeps http://10.129.10.143:9999/.... Repository keys drop ports by design (git.ts#L149).
  2. That host becomes glab's target. The watch reads the MR with getMergeRequestDetail, which runs glab api projects/<path>/merge_requests/<n> (GitLabPullRequestCli.ts#L1595-L1606). GitLabCli passes the host as GITLAB_HOST (GitLabCli.ts#L518). With GITLAB_HOST=10.129.10.143, glab calls https://10.129.10.143:443 and gets connection refused. The same command with GITLAB_HOST=10.129.10.143:9999 succeeds.

This is unchanged on main as of 2026-11-21: GitLabCli.ts still sets GITLAB_HOST: input.host.

The watch also never told the agent that every read was failing. That is a separate bug, filed separately.

Steps to reproduce

  1. Run a self-managed GitLab over HTTP on a non-default port, such as http://10.129.10.143:9999. Log glab in to 10.129.10.143:9999 with the HTTP API protocol.
  2. Clone a project from it, so the origin is http://10.129.10.143:9999/group/project.git, and add the checkout as a project on a t3 serve 0.1.11 server.
  3. In a thread, have the agent open a merge request, so it is linked with source: "created", and call watch_pull_request until it merges.
  4. Let the pipeline pass and merge the MR.

Expected: the watch reads the MR and wakes the agent when checks pass and when it merges.
Actual: every read of the MR fails, so the watch never wakes.

The failing read, run by hand in the checkout:

  1. GITLAB_HOST=10.129.10.143 glab api 'projects/group%2Fproject/merge_requests/123' fails with connection refused on port 443.
  2. GITLAB_HOST=10.129.10.143:9999 glab api 'projects/group%2Fproject/merge_requests/123' succeeds.

Version

0.1.11 (t3 serve on the remote server where the thread ran, confirmed by its /.well-known/t3/environment; the t3 triage CLI was also 0.1.11)

Environment

Server: t3 serve 0.1.11 as a background service on Debian 13 (Linux 6.12, x64). Client: T3 Code desktop 0.1.11 on Arch Linux. glab 1.131.0. GitLab self-managed over HTTP on port 9999. Agent: Claude (claudeAgent).

Evidence

# Only the project and MR number are anonymized. Times are UTC on 2026-11-21.

# server.trace.ndjson, PullRequestWatchReactor.reportEnd at 11:08:46, after the user had the agent stop the watch
"pull request watch ended" {"pullRequest":"10.129.10.143/group/project#123","reason":"stopped","minutes":26,"quietMinutes":26,"wakes":0,"reads":0,"partial":false}

# PullRequestWatchReactor.sweep, every ~2 minutes from 10:43 (watch start) on
"pull request watch check failed" {"pullRequest":"<projectId> 10.129.10.143/group/project#123"}
  PullRequestOperationError (operation: detail)
  > PullRequestProviderError (provider: gitlab, operation: getChangeRequest, reason: failed)
  > GitLabCliCommandError (operation: execute, command: glab)
  > VcsProcessExitError (argumentCount: 2, exitCode: 1, stderrLength: 272, failureKind: command-failed)

# The thread's PR link in statev2.sqlite: the host has no port, the url does
{"host":"10.129.10.143","repository":"group/project","number":123,"url":"http://10.129.10.143:9999/group/project/-/merge_requests/123","source":"created"}

# The same glab read, rerun by hand in the checkout
$ GITLAB_HOST=10.129.10.143 glab api 'projects/group%2Fproject/merge_requests/123'
ERROR  Get "https://10.129.10.143/api/v4/projects/group%2Fproject/merge_requests/123": dial tcp 10.129.10.143:443: connect: connection refused.
$ GITLAB_HOST=10.129.10.143:9999 glab api 'projects/group%2Fproject/merge_requests/123'
# exit 0: state=merged, merged_at=2026-11-21T11:06:12Z, head_pipeline.status=success

# An earlier watch on another MR in the same project ended the same way: 8 minutes, wakes 0, reads 0.

Related issues

#16463 (self-hosted GitLab MR links fail when SSH and API hostnames differ; that one is a different hostname, this one is a dropped port) and #39655 (Add to another machine drops the port for the same kind of GitLab, in a different code path) are close but not duplicates. #22342 is why glab's error never reached the trace.

Fix applied or workaround

Nothing was changed on the machine during triage. The reporter now tells their agents to wait on merge requests with their own mr-wait script, which calls glab directly, instead of T3 Code's built-in watch_pull_request.

Filed by

Claude Code (Claude Opus 5.5, claude-opus-5-5) via t3 triage

Activity

  1. added
    via-triage
    on Nov 21, 2026
  2. ahmedisam99 commented on Nov 21, 2026

    @ahmedisam99
    Author

    Note

    🤖 Claude Opus 5.5 responding on behalf of ahmedisam99

    The same dropped port also stops "Auto-settle merged threads" for these threads: the server never records that the MR merged.

    PullRequestSyncReactor keeps each linked PR's snapshot current through getChangeRequestSummary. On GitLab that calls the same getMergeRequestDetail with the port-less host (GitLabPullRequestProvider.ts#L335-L344). Every sync failed, so the link's snapshot stayed null. resolveAutoSettlementAt returns early whenever a link has no snapshot (ThreadSettlementService.ts#L224). Auto-settle on merge is on (the default, not overridden in the server's settings.json), yet the thread stayed active after the MR merged at 11:06:12.

    # server.trace.ndjson, PullRequestSyncReactor.sweep "pull request sync skipped", per MR (UTC, 2026-11-21)
    11x 10.129.10.143/group/project#123 | Pull request operation summary failed: GitLab CLI command failed. | 10:42:54 -> 11:52:37
    10x 10.129.10.143/group/project#122 | Pull request operation summary failed: GitLab CLI command failed. | 10:40:49 -> 12:02:37
    
    # statev2.sqlite: every PR link on this host (3) has snapshot: null

    #39282 (closed) had the same symptom, GitLab MRs that never sync so auto-settle never fires, but from a different cause: a host with no T3 project.

  3. JoeyMa-zh commented on Nov 24, 2026

    @JoeyMa-zh

    Independently hit this on Nightly (macOS, glab 1.124.0) with a self-managed GitLab at http://<ip>:32023 (http + non-standard port). Same mechanism as the diagnosis above: repository identity/canonical key stored the host without the port, GitLabCli passed GITLAB_HOST=<ip> to glab, glab defaulted to https://<ip>:443 and every call exited 1.

    Additional symptom — the MR detail panel hangs forever. Beyond watches not waking the agent: opening any linked MR renders the panel skeleton (title bar, tabs, sidebar) but the content never loads and no error is surfaced anywhere. server.trace.ndjson shows every ws.rpc.pullRequests.detail span failing with VcsProcessExitError: glab exited with 1 → PullRequestOperationError: Pull request operation detail failed: GitLab CLI command failed. (the generic message from #22342), including getProjectMergeCapabilities. So users see an infinite spinner rather than a failure — worth covering in the fix's QA.

    Verified from a normal shell that the identical command succeeds when the port survives:

    $ cd <checkout> && GITLAB_HOST=<ip>:32023 glab api "projects/<group>%2F<project>?license=false"   # → 200
    $ cd <checkout> && GITLAB_HOST=<ip>          glab api "projects/<group>%2F<project>?license=false"   # → connection refused on port 443, exit 1
    

    Workaround that unblocks the panel today (no T3 changes needed): register a portless host entry in glab that redirects API traffic to the real endpoint, reusing the existing token:

    glab auth login --hostname <ip> --api-host <ip>:32023 --api-protocol http --stdin < <token>
    

    With that entry present, GITLAB_HOST=<ip> resolves to http://<ip>:32023/api/v4 and the MR panel, watches, and PR tools all work again. Once #40321 lands, the entry can be removed with glab auth logout --hostname <ip>.

    One caveat: any repository identity created while the bug was live still stores the portless host, so identities may need re-creation even on a fixed build.

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

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions