Skip to content

[Bug]: Forgejo issue tracker fails on SSH host-alias remotes (alias:owner/repo.git) even when fj has a matching alias #38359

Not planned

Description

@santenauta

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. Give a repo a remote that uses a host alias from ~/.ssh/config: origin myforge:owner/repo.git, where Host myforge points at the Forgejo server's SSH address.
  2. Install fj 0.7.0 and log in with fj -H https://forge.example.com auth add-token. Make sure keys.json maps the alias: "aliases": {"myforge": "forge.example.com"}.
  3. Add the repo as a project. It is correctly detected as Forgejo (canonical key myforge/owner/repo).
  4. Open the Issues page, or call list_issues for that project.

Expected behavior

The Issues page lists the repo's issues through the fj login, which the alias maps to this remote.

Actual behavior

The project shows "Install Forgejo CLI (fj 0.6 or later) or Gitea CLI (tea 0.16 or later) and retry." even though fj is installed and fj -H https://forge.example.com whoami succeeds. The same token reads the repo's issues fine through the API.

From reading the bundled code:

  • ForgejoIssueTracker passes host: "myforge", the first part of the canonical key, to ForgejoCli.api.
  • resolveTarget then only looks in git remote -v for http(s):// remotes on that host. It finds none, so it builds a non-SSH remote with host myforge and an empty path.
  • matchForgejoLogin then requires url.host === "myforge", so it skips the fj login and the aliases / ssh_host match.
  • That leaves tea. It isn't installed, so the user gets the misleading "install" message.

Without a host, the same lookup matches the login correctly.

Suggested fix: when the requested host is an SSH remote host, match it the way SSH remotes are matched elsewhere (fj aliases / ssh_host). Also, when fj is present, the error should say "no matching login" rather than "install".

Related: #29753 (same SSH-host vs web-host split, in the review guide).

Impact

Minor bug or occasional failure

Version or commit

0.1.11-nightly.20261117.4825

Environment

macOS, T3 Code (Nightly) desktop app, fj 0.7.0, tea not installed

Activity

  1. juliusmarminge commented on Nov 17, 2026

    @juliusmarminge
    Member

    @santenauta On the Issues page, what host does the Forgejo group header show next to 'Forgejo' for this project: myforge or forge.example.com? (If it shows forge.example.com, please also say how fj was installed, e.g. via cargo into ~/.cargo/bin, since the desktop app may not see it on its PATH.)

  2. added
    needs more info
    on Nov 17, 2026
  3. mdmdj commented on Nov 20, 2026

    @mdmdj

    Adding a second reproduction on 0.1.11, on the pull-request sync path as well as Issues, with a local plain-HTTP server.

    • T3 Code 0.1.11; server on WSL2/Linux, desktop client on Windows
    • fj 0.7.0; keys.json has forgejo.local:13000; fj -H http://forgejo.local:13000 whoami succeeds
    • origin = ssh://forgejo/owner/repo.git; Host forgejo points at the same machine, port 222
    • Forgejo is self-hosted on the same machine, HTTP-only at http://forgejo.local:13000 (nonstandard port; no TLS needed for loopback/LAN)

    T3 logs SourceControlProviderError: Source control provider forgejo failed in listChangeRequests: Install Forgejo CLI (fj 0.6 or later) or Gitea CLI (tea 0.16 or later) and retry. The trace shows ForgejoCli.listLogins succeeding while reading the fj keys, then falling back to tea and failing to spawn it, which is where the install hint comes from.

    Two additions to the diagnosis:

    1. This is not limited to the Issues page; branch PR lookup and sync hit it too.
    2. Reading resolveTarget, the SSH branch passes context.provider.baseUrl (https://forgejo) as the scheme hint, so publicLogins builds https://<fj-host:port>. On an HTTP-only server that cannot authenticate even once the alias mapping makes the login match. The only arrangement we found that works is making the selected remote an http:// URL and keeping pushurl ssh://forgejo/..., which then requires the token as a Git HTTP password. None of this is in the docs.

    I filed the documentation gap separately: #39661.

    Happy to provide trace spans or test a patch.

  4. removed
    needs more info
    on Nov 20, 2026
  5. juliusmarminge commented on Nov 20, 2026

    @juliusmarminge
    Member

    @santenauta On the Issues page, does the Forgejo group header show myforge or forge.example.com, and what does which fj print in a terminal? The macOS desktop app may not see a binary in a folder such as ~/.cargo/bin; on current main your exact message appears only when the server cannot find fj.

  6. added
    needs more info
    on Nov 20, 2026
  7. removed
    needs more info
    on Nov 21, 2026
  8. juliusmarminge commented on Nov 27, 2026

    @juliusmarminge
    Member

    Closing: no reply in 7 days after we asked for more information. Comment with the missing details and we will reopen.

  9. LoganRupe commented on Nov 30, 2026

    @LoganRupe

    I hit this on 0.1.13 (macOS desktop, fj 0.7.0 from Homebrew, gt not installed) and can answer both questions.

    The Forgejo group header on the Issues page shows the SSH alias host, not the web host. fj is in /opt/homebrew/bin, which is on the desktop server's PATH. I put a logging wrapper in front of fj and T3 never ran it; the trace shows ForgejoCli.listLogins succeeding, then a gt spawn failing, which is where the install message comes from.

    How the alias reaches the explicit host lookup: my projects were added before fj had a login. While fj has no login for a remote, the registry caches "no provider for this remote" for an hour (SourceControlProviderRegistry.ts, UNKNOWN_REMOTE_CACHE_TTL), and only a settings change clears it, not a change to fj's keys.json. Until that expires the identity has no web URL, so the Forgejo definition falls back to the alias hostname and the issue tracker passes that as host. I saw it on every Forgejo project for about an hour after fj auth add-token; one project recovered on its own and another was still failing when I wrote this.

    My setup also differs from your repro in one way that matters: the remote is ssh://[email protected]:2222/owner/repo.git, so fj stores the alias with its port (alias.example:2222) while the tracker asks for the bare hostname alias.example. resolveTarget finds no HTTP remote on that host, builds a non SSH remote, and matchForgejoLogin then compares web hosts only, so the aliased login never matches. #38990 compared ssh_host to the bare requested host, which misses whenever the alias carries a port.

    I have a fix with a unit test that fails on current main (expected [ 'git', 'gt' ] to deeply equal [ 'git', 'fj' ]) and passes with the change. PR to follow.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions