fix(branch): validate generated branch name under commit signing (#1582)

The non-signing path validated newBranch before checkout, but the
use_commit_signing path passed it straight to the file ops server, so an
invalid branch_name_template surfaced only as a 422 "Reference name is
not valid" on the first commit.

Validate once after the name is resolved so both paths fail early with
the same message.

Fixes #1573
This commit is contained in:
Rishav Naskar
2026-08-07 07:59:43 -07:00
committed by GitHub
parent ecf573bd65
commit b704dd3960
2 changed files with 85 additions and 1 deletions
+5 -1
View File
@@ -288,6 +288,11 @@ export async function setupBranch(
// Branch doesn't exist (non-zero exit code), continue with generated name
}
// Validate before either path uses the name. The signing path hands it to
// the file ops server rather than to git, so without this an invalid
// template only surfaces as a 422 on the first commit.
validateBranchName(newBranch);
// For commit signing, defer branch creation to the file ops server
if (context.inputs.useCommitSigning) {
console.log(
@@ -315,7 +320,6 @@ export async function setupBranch(
// Fetch and checkout the source branch first to ensure we branch from the correct base
console.log(`Fetching and checking out source branch: ${sourceBranch}`);
validateBranchName(sourceBranch);
validateBranchName(newBranch);
execGit(["fetch", "origin", sourceBranch, "--depth=1"]);
execGit(["checkout", sourceBranch, "--"]);