Skip to content

[Bug]: Azure DevOps Commit, Push & PR fails when default branch is master #5262

Description

@kustomq

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Open an Azure DevOps Git repository in T3 Code where:

    • The default branch is master.

    • No local or remote main branch exists.

    • Azure CLI and the Azure DevOps extension are installed and authenticated.

    • The repository remote resembles:

      https://ORGANIZATION.visualstudio.com/PROJECT/_git/REPOSITORY
      
  2. Confirm the remote default branch:

    git symbolic-ref --short refs/remotes/origin/HEAD

    Output:

    origin/master
    
  3. Confirm that main does not exist:

    git rev-parse --verify main

    Output:

    fatal: Needed a single revision
    
  4. Create a feature branch:

    git switch -c test/t3code-azure-pr
  5. Make a small file change.

  6. In T3 Code, click Commit, push & PR.

  7. Observe that the commit and push complete successfully.

  8. The flow then reaches the pull-request preparation/content-generation phase and fails.

  9. Check Azure DevOps. The feature branch exists remotely, but no pull request was created.

The underlying Azure CLI behavior can also be reproduced directly:

az repos show --detect true

Output:

ERROR: the following arguments are required: --repository/-r

Providing the repository succeeds:

az repos show \
  --detect true \
  --repository REPOSITORY \
  --query defaultBranch \
  --output tsv

Output:

refs/heads/master

Expected behavior

The Commit, push & PR action should:

  1. Commit the selected changes.
  2. Push the feature branch.
  3. Resolve the Azure DevOps repository’s default branch as master.
  4. Generate the PR title and description using the correct master...HEAD range.
  5. Create an Azure DevOps pull request from the feature branch into master.
  6. Display a success notification with a link to the created pull request.

If the default branch cannot be resolved, T3 Code should stop before generating PR content and display a clear default-branch detection error.

Actual behavior

T3 Code:

  1. Successfully commits the changes.

  2. Successfully pushes the feature branch.

  3. Attempts to resolve the Azure DevOps default branch by running:

    az repos show --detect true
    
    

Impact

Major degradation or frequent failure

Version or commit

No response

Environment

No response

Logs or stack traces

### 4 — Logs or stack traces


The first relevant failure in the T3 Code server trace is:

VcsProcessExitError: VCS process failed in AzureDevOpsCli.execute:
az (...) exited with 2 - Process exited with a non-zero status.

    at VcsProcessExitError.fromProcessExit
    at VcsProcess.run
    at resolveBaseBranch
    at runPrStep
    at runStackedAction.runAction
    at runStackedAction

The Azure CLI command fails with:

ERROR: the following arguments are required: --repository/-r

https://aka.ms/cli_ref
Read more about the command in reference docs

T3 Code then falls back to `main`, after which the final failure is:

GitCommandError: Git command failed in
GitVcsDriver.readRangeContext.log (...):
Git command exited with a non-zero status.

    at readRangeContext
    at runPrStep
    at runStackedAction.runAction
    at runStackedAction

A subsequent attempt can fail in the same flow at:

GitCommandError: Git command failed in
GitVcsDriver.readRangeContext.diffStat (...):
Git command exited with a non-zero status.

Relevant source flow:

apps/server/src/sourceControl/AzureDevOpsCli.ts

getDefaultBranch executes:

args: ["repos", "show", "--detect", "true"]

The required Azure DevOps repository argument is missing.

apps/server/src/git/GitManager.ts

The provider error is suppressed:

const defaultFromProvider = yield* sourceControlProvider(cwd).pipe(
  Effect.flatMap((provider) => provider.getDefaultBranch({ cwd })),
  Effect.orElseSucceed(() => null),
);

The fallback is hardcoded:

return "main";

That invalid base is later used here:

const baseRangeRef = yield* resolveBaseRangeRef(cwd, baseBranch);
const rangeContext = yield* gitCore.readRangeContext(cwd, baseRangeRef);

Environment:

T3 Code: 0.0.32-nightly.20260803.986
macOS: 26.5.2
Git: 2.53.0
Azure CLI: 2.88.0
Azure DevOps CLI extension: 1.0.6
Source-control provider: Azure DevOps

Screenshots, recordings, or supporting files

No response

Workaround

Explicitly configure the merge base for the current feature branch:

git config "branch.$(git branch --show-current).gh-merge-base" master

Then retry the Create PR action in T3 Code.

T3 Code checks this Git configuration before attempting Azure DevOps default-branch detection, so it uses master instead of falling back to main.

The configuration can be verified with:

git config --get "branch.$(git branch --show-current).gh-merge-base"

Expected output:

master

This is only a per-branch workaround. New feature branches require the same configuration until T3 Code correctly supplies --repository to Azure CLI or resolves the default branch from origin/HEAD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions