Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Images in private Forgejo/Gitea pull request descriptions do not load #18757

Opengustavohariel(GitHub profile, opens in a new tab) opened this issue 3 comments

Area: apps/web, apps/server (PR viewer, asset proxy)

AI disclosure: This report was drafted by Claude (Sonnet 5.5) running in Claude Code inside T3 Code, from checks the reporter asked it to run. The reporter reviewed and is submitting it.

Steps to reproduce

  1. Connect a project whose origin is on a self-hosted Forgejo/Gitea instance, with the repository set to private. Sign in with fj auth login (or fj auth add-token).
  2. Open a pull request on that repository whose description embeds an image, i.e. a pasted screenshot that Forgejo stores as https://<host>/attachments/<uuid>.
  3. Open that pull request in the T3 Code Pull Requests view.

Expected behavior

The embedded image renders, as it does in the Forgejo web UI and as private GitHub PR images do since #11706.

Actual behavior

The image is broken. The markdown renderer puts the raw attachment URL in an <img>, so the browser requests it with no credentials. Forgejo serves attachments with the repository's visibility, so a private repository's attachment answers anonymously with 404:

$ curl -s -o /dev/null -w "%{http_code}\n" https://<host>/attachments/<uuid>
404
$ curl -s -o /dev/null -w "%{http_code} %{content_type}\n" \
    -H "Authorization: token <token from fj>" https://<host>/attachments/<uuid>
200 image/png

The token used above is the one fj already stores, which ForgejoCli already reads (packages/source-control-forgejo/src/server/ForgejoCli.ts, authenticateFj).

Impact

Major degradation or frequent failure: every screenshot in a PR description on a private Forgejo/Gitea repository is unreadable inside T3 Code.

Version or commit

Desktop nightly (closed build). Code checked against main @ 9e552285.

Environment

Linux (Omarchy), T3 Code desktop nightly, Forgejo provider with fj.

Workaround

None that keeps the attachments private. Opening the PR in the Forgejo web UI shows the images. Making the repository public would too, but that is not an option here.

  • #6600 (GitHub, closed) and #11706 (merged): the same symptom, fixed by a server-side media proxy behind signed /api/assets URLs.
  • #11412 (GitLab, open): the same symptom for private GitLab uploads.
  • #11436 added the Forgejo/Gitea provider. I found no existing issue for private attachments on it.

Possible direction

If maintainers agree this is in scope, I would follow #11706's design rather than invent a new one: a forgejo-media claim in contracts/assets.ts, a fetch that sends the fj token only to the exact configured Forgejo origin (and never to a redirect target), and a URL classifier in the PR markdown renderer. I will not open a PR until a maintainer has triaged this, per CONTRIBUTING.md.

  1. Classified as an ordinary bug: the report describes images failing to load, with no exploitable vulnerability. Checked all 19 pages of open issues; the private GitLab, Bitbucket and GitHub media reports concern different providers, so this is not a duplicate. Runtime reproduction is blocked in this Linux environment: fj is unavailable and no authenticated private Forgejo/Gitea fixture is provided. No app reproduction is claimed. A fix requires authenticated attachment fetching and credential forwarding, which the automated triage rules reserve for maintainer review. Leaving this issue open for that review.

  2. Fresh triage under revised brief 4ed4f1d on main at 07d38b8d17. This is an ordinary bug; credential handling is no longer a reason to stop a fix. Checked all 19 pages of open issues and all 28 pages of open PRs; no matching Forgejo/Gitea attachment report or fix was found. Runtime reproduction remains blocked before the first reported step: this Linux environment has no fj executable, no ~/.local/share/forgejo-cli/keys.json, and no supplied private Forgejo/Gitea repository/account. No real-app reproduction is claimed. Leaving the issue open; authenticated private-repository access is required to verify the reported failure.

  3. tanstack-source added labelsbug

  4. More context on Gitea, checked against T3 main at 49c3ab86 (2026-11-17) and Gitea's source. Forgejo and Gitea now write upload links differently, and #35425 covers only Forgejo's form.

    Forgejo. Its editor writes ![name](/attachments/<uuid>), relative to the origin (web_src/js/features/comp/Paste.js on the forgejo branch). main resolves that against the origin, and #35425's mediaUrl (^/attachments/<uuid>$) claims it.

    Gitea 1.22.1 and later (go-gitea/gitea#31235, now generateMarkdownLinkForAttachment in web_src/js/features/dropzone.ts) writes the link relative to the repository, with no leading slash:

    • image: ![name](attachments/<uuid>)
    • high-DPI PNG (since 1.22, go-gitea/gitea#29123): <img width="…" alt="name" src="attachments/<uuid>">
    • video, on current Gitea: <video src="attachments/<uuid>" title="name" controls></video>

    Gitea's code comment says these resolve to /<sub-path>/<owner>/<repo>/attachments/<uuid>. go-gitea/gitea#27486 (1.22) lets that repository route accept a personal access token.

    What T3 does with Gitea's form, from reading main:

    • remarkChangeRequestMediaUrls only rewrites links that start with /. So attachments/<uuid> reaches classifyMarkdownImageSource as a relative path and is looked up as <cwd>/attachments/<uuid> on the machine running T3.
    • The plugin only visits markdown image/definition nodes, so the src in raw <img>/<video> HTML is never rewritten.
    • With #35425 applied it would still fail. Its mediaUrl doesn't claim /<owner>/<repo>/attachments/<uuid>, or an instance under a sub-path (/<sub>/attachments/<uuid>), and nothing resolves the relative form against the repository URL.

    Suggested additions to #35425 (or a follow-up):

    1. Resolve attachments/<uuid> against the PR's repository URL. #23501 does the same for GitLab's /uploads/… with an isRepositoryRelativePath hook.
    2. Claim /<owner>/<repo>/attachments/<uuid> and sub-path instances in mediaUrl. Fetch from whichever route accepts the token on Gitea; #27486 added token access on the repository route.
    3. Apply the same resolution to src in raw <img>/<video> HTML, which Gitea uses for high-DPI screenshots and every video.

    I haven't run this against a live private Gitea instance. The link forms come from Gitea's source and PR history, and the T3 behaviour from reading main. GitLab has the same project-relative problem, tracked in #11412 / #23501.

Sign in to join this conversation.