`gh issue develop --name <existing-branch>` fails with "API returned empty branch name" instead of saying the branch already exists

Đang mở Phù hợp với người mới
#14,946 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github, go
Lĩnh vực
api, cli

Hướng nghiên cứu

Bắt đầu bằng cách lần theo lệnh gh issue develop --name đến mutation createLinkedBranch và kiểm tra cách phản hồi được xử lý khi linkedBranch là null. Thêm giải thích hữu ích cho trường hợp này và kiểm tra các bài kiểm thử lệnh hiện có về việc tạo nhánh và xử lý lỗi. Công việc được xem là hoàn tất khi thao tác thử dùng một nhánh remote hiện có báo nguyên nhân thay vì “API returned empty branch name.”

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

needs-triage
Describe the bug

When --name is a branch that already exists on the remote, gh issue develop fails with:

failed to create linked branch: API returned empty branch name

The message points at the API response, not the cause. The underlying createLinkedBranch mutation returns HTTP 200 with {"data":{"createLinkedBranch":{"linkedBranch":null}}} and no errors, and nothing is linked or created.

This is likely the real cause behind #13805, which was closed without a reproduction: that report blamed the slash in the branch name, but the test below shows an existing branch fails with or without a slash, and a new branch with a slash works.

Affected version

gh version 2.92.0 (2026-04-28), Linux

Steps to reproduce the behavior
  1. In any repository, push two branches: example and feat/example.
  2. Open an issue.
  3. Run gh issue develop <issue> --repo <owner>/<repo> --name example --base example.
  4. See failed to create linked branch: API returned empty branch name. gh issue develop --list <issue> shows nothing linked.
  5. Repeat with --name feat/example --base feat/example: same error.
  6. Run gh issue develop <issue> --repo <owner>/<repo> --name feat/new-example --base main: the branch is created and linked.
Tested

Private repository, gh 2.92.0, every branch pointing at the same main commit:

Branch passed to --name Already on remote? Result
example yes API returned empty branch name, exit 1, nothing linked
feat/example yes API returned empty branch name, exit 1, nothing linked
feat/new-example no branch created and linked (--list shows it)

Request ID of a failing mutation (from GH_DEBUG=api): DB0E:26CBEE:1EB28F1:2CA6176:6AEC648D

The third run was made outside a git checkout, so it also exited 1 with fatal: not in a git directory after creating the branch; that is #14856.

Expected vs actual behavior

Expected: before calling createLinkedBranch, check whether the branch already exists and say so, for example "branch example already exists; the API can only link a new branch. Link it from the issue's Development sidebar." Or check for a null linkedBranch and explain it.

Actual: a generic "empty branch name" error.

Additional context

The API side (no way to link an existing branch, and the silent null) is reported in https://github.com/orgs/community/discussions/212130.

Ngôn ngữ chính
Go
Star
46.9k
Fork
9.2k
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
60

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cli/cli

Tất cả issue của cli/cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.