Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: A scheduled task that opens a thread per run bases its worktree on a hardcoded "main", so it fails on repos whose default branch is master #26260

Closedalexlwn123(GitHub profile, opens in a new tab) opened this issue 2 comments

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. Use a project whose repository's default branch is master and has no main branch, locally or on origin.
  2. Create a scheduled task with schedule_task and bindToCurrentThread: false (a new thread per run). Here it was a webhook trigger, { "type": "webhook", ... }.
  3. Fire it (here, a GitHub pull_request delivery).
  4. The new thread fails in workspace preparation. Retry fails the same way.

Expected behavior

The run's worktree starts from the project's default branch (origin/master here, which refs/remotes/origin/HEAD names), as threads started by hand in the same project do.

Actual behavior

Workspace preparation failed during provision worktree: Git command failed in GitVcsDriver.createWorktree (<repo>): git worktree add failed (ref_not_found)

schedule_task takes no workspace argument, and for an unbound task scheduledTaskWorkspaceStrategy hardcodes the base:

function scheduledTaskWorkspaceStrategy(boundToThread) {
  return boundToThread ? { type: "root" } : {
    type: "worktree",
    baseRef: "main",
    startFromOrigin: true
  };
}

The task row stores {"type":"worktree","baseRef":"main","startFromOrigin":true}. At launch, resolveWorktreeBaseRemote("main") finds no local main and falls back to origin/main, which doesn't exist, so the fetch yields nothing and startRef stays the literal main. GitVcsDriver.createWorktree then runs git worktree add -b t3/… -- <path> main, which git rejects, and T3 classifies that as ref_not_found.

A fix could take the base from the project's default branch for unbound tasks, or let schedule_task accept a base ref.

Impact

Blocks work completely

Version or commit

0.1.4-nightly.20261027.3770

Environment

macOS 15.6.1 (arm64), desktop app; git 2.39.5; provider Claude (claude-opus-5-5), full access

Logs or stack traces

ThreadLaunchError: Thread launch scheduled-task:…:webhook:delivery:relay:… failed during provision-worktree.
    at ThreadLaunchService.prepareInBackground
    at ThreadLaunchService.launch
    at ScheduledTaskService.runTask
    at ScheduledTaskService.runWebhookDelivery
  [cause]: GitCommandError: Git command failed in GitVcsDriver.createWorktree (<repo>): git worktree add failed (ref_not_found)

# the same command by hand, in the project's clone:
$ git worktree add -b t3/probe -- /tmp/probe main
Preparing worktree (new branch 't3/probe')
fatal: not a valid object name: 'main'

Workaround

A local main that tracks the default branch: git branch --track main origin/master. resolveWorktreeBaseRemote then reads its upstream, fetches origin/master, and starts the worktree there.

Related: #17889 (a failed scheduled run is recorded as succeeded) shows here too, since the task reports lastRunStatus: succeeded while its thread failed. That's a separate bug, so this isn't a duplicate.

Investigated and written up by Claude (claude-opus-5-5) in a T3 Code thread.

  1. I opened #26465 for this. For unbound schedule_task tasks, it saves the project's origin/HEAD branch as the worktree base, and keeps "main" when origin/HEAD isn't set. Bound tasks and the web/mobile scheduled-task forms are unchanged.

    I checked it against real git locally. On a clone whose origin has only master, the old "main" base reproduces the ref_not_found failure from this report. The new base creates the worktree at origin/master. A repo whose origin was added by hand has no origin/HEAD, so it still falls back to "main". The PR lists that as a known limitation.

  2. Closing as a duplicate of #16183, which tracks the same problem. Please follow along there.

  3. juliusmarminge closed this

Sign in to join this conversation.