Skip to content

Publishing to Forgejo fails in a repo with no commits: fj whoami runs in the project folder #26761

Closed

Description

@olschulz

What happened

Publishing a new local project to a self-hosted Forgejo server fails in a repo with no commits yet. The dialog shows only "The source control operation could not be completed." No repository is created on the server. The fj login is valid.

Diagnosis

Before creating the repo, ForgejoCli.authenticateFj (packages/source-control-forgejo/src/server/ForgejoCli.ts:436) runs fj --host <url> whoami with cwd set to the project folder. fj v0.7.0 reads the local git repo even when --host is given. On an unborn branch that read fails and fj exits 1:

Error: could not find host, try specifying with --host

Caused by:
    reference 'refs/heads/main' not found; class=Reference (4); code=UnbornBranch (-9)

The same command exits 0 from any folder that is not a git repo, or from a repo with at least one commit.

The real error is also hidden. For command === "fj", execute (ForgejoCli.ts:218-245) drops cause, so the process stderr is lost. The error gets the generic detail "Forgejo CLI command failed.", and SourceControlRepositoryService.mapRepositoryError then shows the generic "could not be completed" message.

Possible fixes: run the whoami auth check (and other host-only fj calls) outside the project folder, for example in the home directory or a temp folder, because --host already names the server. Separately, pass fj's stderr into the error detail so failures like this can be diagnosed.

Steps to reproduce

  1. Log in to a Forgejo server with fj auth login (or fj auth add-token).
  2. Create a project folder, run git init, and make no commits.
  3. Add it as a project in T3 Code and press Publish, choosing the Forgejo server.
  4. The publish fails with "The source control operation could not be completed."

Without T3: git init -b main /tmp/x && cd /tmp/x && fj --host https://<forgejo-host> whoami exits 1 with the error above.

Version

0.1.4-nightly.20261028.3824 (commit eb751fa). The code path has not changed on main since 2026-10-19 (a195ba0).

Environment

  • T3 Code Desktop 0.1.4-nightly.20261028.3824, with the server running locally on the same build
  • Linux x64 (kernel 7.0.14-25-pve), Node v26.12.1
  • fj v0.7.0, self-hosted Forgejo

Evidence

  • An earlier look at the server trace for the failed publish showed fj --host <url> whoami exiting 1 with cwd set to the empty project folder; a later search of the trace did not find it again.
  • Reproduced by hand in a fresh git init repo (exit 1, UnbornBranch). The same command exits 0 outside the repo.

Related issues

None found. Searched for: fj whoami, forgejo publish, UnbornBranch, "source control operation could not be completed".

Fix applied or workaround

Workaround: make a first commit before pressing Publish.

Filed by

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

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