Problem#
Images and videos uploaded to a private GitLab project's merge request show as "Image unavailable" / "Video unavailable" in the pull request view. GitLab writes uploads as project-relative links (/uploads/<secret>/<name>), which the clients treated as local paths. Even made absolute, a private project only serves them to a signed-in request; without a session GitLab redirects to /users/sign_in.
Change#
- Web and mobile resolve relative
/uploads/ links in GitLab bodies and comments against the project URL. Both clients then map the URL to a new gitlab-media asset, the same way github-media works (one shared pullRequestMediaResource helper in client-runtime).
- The server fetches the upload from GitLab's upload API,
GET /projects/:id/uploads/:secret/:filename. That route exists since GitLab 17.4 and needs only Guest access. The token is the one glab stores for the upload's own host. Ambient GITLAB_TOKEN-style variables are ignored, because the host comes from text someone wrote into the merge request. OAuth logins are refreshed before use, and a 401 drops the cached token.
- Anything the API cannot serve (no
glab login for the host, GitLab before 17.4) answers with a redirect to the upload URL itself, so public projects keep working as before.
- The redirect-following, header forwarding and content-type checks of the existing GitHub media proxy are shared rather than copied (
GitHubMediaFetch.ts → SourceControlMedia.ts). The token never leaves the GitLab origin, including across object-storage redirects.
GraphQL was considered and does not help here: GitLab's GraphQL API does not return file contents, so the REST upload route is the only API path to the bytes.
Scope and approval#
This replaces #15270, which was closed during PR cleanup because it did not state the model and harness. It is the GitLab follow-up to #11374, whose closing comment asked for a fresh, focused patch, rebuilt on the architecture #11706 introduced for GitHub media. Related: #11412. Contract, server, web and mobile changes all serve the same fix: uploads in the existing merge request view. Desktop uses the web renderer.
Not covered: GitLab installs under a relative URL root (https://host/gitlab/...) fall back to the redirect.
Verification#
Against a private, self-hosted GitLab 19.4 merge request with an uploaded PNG and a six-second MP4, in T3's Browser panel (web client):
Before (main) | After |
|---|
 |  |
- After: both elements load from signed
gitlab-media asset URLs. The image decodes at 180×180. The video plays (reached 1.6 s), seeks to 4.0 s, and reports no media error.
- The upload API with the stored bearer token returned 200 for the image and 206 for a video range request. Without a token it returned 404, and the web URL without a session redirected to
/users/sign_in.
Focused tests (79 passing): URL parsing and link resolution, glab credential lookup (stored token only, OAuth refresh, invalidation), the proxy (API URL and bearer token, token kept off a storage redirect, redirect fallback on no login / 404 / 401), signing and refusal of non-upload URLs, and mobile preview sources.
vp test run packages/shared/src/gitlabMedia.test.ts packages/source-control-gitlab/src/server/GitLabCredentials.test.ts apps/server/src/assets/AssetAccess.test.ts packages/client-runtime/src/pullRequestMarkdown.test.ts apps/mobile/src/features/pull-requests/pullRequestMediaSource.test.ts
Typecheck passes for server, web, mobile, contracts, shared, client-runtime and source-control-gitlab. Targeted lint has no errors. Not run on a native mobile device or the packaged desktop app.
Written by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, run from T3 Code.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed