Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 50602f8

Browse files
authored
Merge pull request #39 from afrisalyp/issue-272-1
Handle broken user assignment. Handle get tc username with no criteria.
2 parents d5d32fb + 561193b commit 50602f8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

services/IssueService.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@ async function handleIssueUnAssignment(event, issue) {
658658

659659
if (dbIssue.assignee) {
660660
const assigneeUserId = gitHelper.getUserIdByLogin(event, dbIssue.assignee);
661+
if (!assigneeUserId) {
662+
// The assignement of this user was failed and broken.
663+
// We don't need to handle the unassignment.
664+
return;
665+
}
661666
logger.debug(`Looking up TC handle of git user: ${assigneeUserId}`);
662667
const userMapping = await userService.getTCUserName(event.provider, assigneeUserId);
663668

services/UserService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ async function getTCUserName(provider, gitUser) {
3939
criteria.gitlabUsername = gitUser;
4040
}
4141
}
42+
if (_.isEmpty(criteria)) {
43+
throw new Error('Can\'t find the TCUserName. Invalid gitUser.');
44+
}
4245
return await dbHelper.scanOne(models.UserMapping, criteria);
4346
}
4447

0 commit comments

Comments
 (0)