Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit ad9a61b

Browse files
committed
fix: sanitize PR labels before GitHub API call
1 parent 117aac1 commit ad9a61b

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/bot.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,34 @@ jobs:
9393
echo "labels=$LABELS" >> $GITHUB_OUTPUT
9494
9595
- name: Apply labels
96-
if: steps.analyze.outputs.labels != ''
9796
uses: actions/github-script@v7
9897
with:
9998
github-token: ${{ steps.app-token.outputs.token }}
10099
script: |
100+
const raw = "${{ steps.analyze.outputs.labels }}";
101+
102+
if (!raw || raw.trim().length === 0) {
103+
console.log("No labels to apply");
104+
return;
105+
}
106+
107+
const labels = raw
108+
.split(",")
109+
.map(l => l.trim())
110+
.filter(l => l.length > 0);
111+
112+
if (labels.length === 0) {
113+
console.log("Labels resolved to empty after filtering");
114+
return;
115+
}
116+
117+
console.log("Applying labels:", labels);
118+
101119
await github.rest.issues.addLabels({
102120
owner: context.repo.owner,
103121
repo: context.repo.repo,
104122
issue_number: context.payload.pull_request.number,
105-
labels: "${{ steps.analyze.outputs.labels }}".split(",")
123+
labels,
106124
});
107125
108126
- name: Comment on PR

0 commit comments

Comments
 (0)