You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added auto-assign github workflow
* Minor update to auto-assign.yml
* Minor update to auto-assign.yml
* Minor update to auto-assign.yml
* Minor update to auto-assign.yml
* Minor update to auto-assign.yml
throw new Error(`Assignment failed for ${user} on issue #${issueNumber}: ${error.message || error}`);
134
210
}
135
211
136
212
console.log(`${user} currently has ${totalAssigned} open issues assigned across ${owner}`);
@@ -151,7 +227,7 @@ jobs:
151
227
// if over limit (but this creates noise in notifications).
152
228
//
153
229
// Current implementation: Option 1 (accept transient violations for simplicity).
154
-
if (totalAssigned >= 2) {
230
+
if (totalAssigned >= userMaxAssignments) {
155
231
const message = `⚠️ @${user} already has ${totalAssigned} open assignments across the org. Please finish or unassign before taking new ones.`;
156
232
await github.rest.issues.createComment({
157
233
owner,
@@ -163,6 +239,48 @@ jobs:
163
239
return;
164
240
}
165
241
242
+
// Re-verify the count immediately before assignment
243
+
try {
244
+
let reCheckCount = 0;
245
+
for (const r of activeRepos) {
246
+
247
+
// Exit early once limit is detected
248
+
if (totalAssigned >= userMaxAssignments) break;
249
+
250
+
try {
251
+
const assignedIssues = await github.paginate(
252
+
github.rest.issues.listForRepo,
253
+
{
254
+
owner,
255
+
repo: r.name,
256
+
state: "open",
257
+
assignee: user,
258
+
per_page: 100,
259
+
max_items: 500, // Limit to first 500 repos to avoid excessive API calls
260
+
}
261
+
);
262
+
reCheckCount += assignedIssues.length;
263
+
} catch (repoError) {
264
+
console.warn(`Skipping ${r.name} during re-check: ${repoError.message}`);
265
+
}
266
+
}
267
+
268
+
if (reCheckCount >= userMaxAssignments) {
269
+
const message = `⚠️ @${user}, another issue was assigned to you while processing this request. You now have ${reCheckCount} open assignments. Please finish or unassign before taking new ones.`;
270
+
await github.rest.issues.createComment({
271
+
owner,
272
+
repo,
273
+
issue_number: issueNumber,
274
+
body: message,
275
+
});
276
+
console.log("Limit reached after re-check, aborting assignment");
277
+
return;
278
+
}
279
+
} catch (error) {
280
+
console.error("Error during assignment re-check:", error);
281
+
// Continue with assignment since we already passed the first check
282
+
}
283
+
166
284
try {
167
285
await github.rest.issues.addAssignees({
168
286
owner,
@@ -196,6 +314,6 @@ jobs:
196
314
} catch (commentError) {
197
315
console.error(`Failed to post error comment for user ${user} on issue #${issueNumber}:`, commentError);
198
316
// Fall back to marking the workflow as failed if we can't even comment
199
-
core.setFailed(`Assignment failed for ${user} on issue #${issueNumber}: ${error.message || error}`);
317
+
throw new Error(`Assignment failed and unable to notify user: ${error.message || error}`);
0 commit comments