@samitouri / QOSAMI-WSL / commits / 1a2672d7

Pipeline: fix loc/notice PR base branch for non-master runs (#40510)

Both wsl-build-nightly-localization.yml and wsl-build-notice.yml derived the PR target branch from Build.SourceBranchName, which Azure DevOps documents as the leaf segment after the last '/' in the source ref. For refs/heads/master that happens to round-trip ('master'), so scheduled runs work; but a manual queue against any branch with slashes (e.g. user/benhill/loc-pipeline-debug) sends only the leaf ('loc-pipeline-debug') as the PR base, which GitHub rejects with 422 Validation Failed: base invalid. This is the same bug PR #14492 introduced when it parameterized the target branch -- the truncation case was never exercised because the real schedule only runs on master. Use Build.SourceBranch and strip the 'refs/heads/' prefix at runtime so the full branch name is preserved. master nightlies are unaffected ('refs/heads/master' -> 'master'). Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Ben Hillis committed May 12, 2026 at 14:26 UTC 1a2672d7a8da8e1f864c103b1e8fbcd6fff0bacc
2 files changed +7 -2
.pipelines/wsl-build-nightly-localization.yml
+6 -1
@@ -17,8 +17,13 @@ schedules:
17 - "master"
18 always: true
19
20 +# Build.SourceBranchName is only the leaf segment of the ref (e.g.
21 +# 'loc-pipeline-debug' for refs/heads/user/benhill/loc-pipeline-debug), which
22 +# fails GitHub's pulls API with a 422 'base invalid' when the branch name
23 +# contains slashes. Strip 'refs/heads/' from the full ref instead so the PR
24 +# targets the actual branch the pipeline ran against.
25 variables:
21 - targetBranch: ${{ variables['Build.SourceBranchName'] }}
26 + targetBranch: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
27
28 pool:
29 vmImage: 'windows-latest'
.pipelines/wsl-build-notice.yml
+1 -1
@@ -4,7 +4,7 @@ trigger:
4 - master
5
6 variables:
7 - targetBranch: ${{ variables['Build.SourceBranchName'] }}
7 + targetBranch: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
8
9 pool:
10 vmImage: 'windows-latest'