@@ -194,6 +194,14 @@ async function handleIssueAssignment(event, issue, force = false) {
194
194
try {
195
195
dbIssue = await ensureChallengeExists ( event , issue ) ;
196
196
197
+ if ( ! dbIssue ) {
198
+ const err = errors . internalDependencyError ( `Can't find the issue in DB. It's not found or not accessible` ) ;
199
+ // The dbissue is not found, the db is not accessible, or the issue is still in creation process.
200
+ // Handle it for rescheduling.
201
+ await eventService . handleEventGracefully ( event , issue , err ) ;
202
+ return ;
203
+ }
204
+
197
205
// Handle multiple assignees. TC-X allows only one assignee.
198
206
if ( event . data . issue . assignees && event . data . issue . assignees . length > 1 ) {
199
207
const comment = 'Topcoder-X only supports a single assignee on a ticket to avoid issues with payment' ;
@@ -302,6 +310,14 @@ async function handleIssueUpdate(event, issue) {
302
310
try {
303
311
dbIssue = await ensureChallengeExists ( event , issue , false ) ;
304
312
313
+ if ( ! dbIssue ) {
314
+ const err = errors . internalDependencyError ( `Can't find the issue in DB. It's not found or not accessible` ) ;
315
+ // The dbissue is not found, the db is not accessible, or the issue is still in creation process.
316
+ // Handle it for rescheduling.
317
+ await eventService . handleEventGracefully ( event , issue , err ) ;
318
+ return ;
319
+ }
320
+
305
321
if ( dbIssue . title === issue . title &&
306
322
dbIssue . body === issue . body &&
307
323
dbIssue . prizes . length === issue . prizes . length &&
@@ -345,6 +361,15 @@ async function handleIssueClose(event, issue) {
345
361
let dbIssue ;
346
362
try {
347
363
dbIssue = await ensureChallengeExists ( event , issue ) ;
364
+
365
+ if ( ! dbIssue ) {
366
+ const err = errors . internalDependencyError ( `Can't find the issue in DB. It's not found or not accessible` ) ;
367
+ // The dbissue is not found, the db is not accessible, or the issue is still in creation process.
368
+ // Handle it for rescheduling.
369
+ await eventService . handleEventGracefully ( event , issue , err ) ;
370
+ return ;
371
+ }
372
+
348
373
event . dbIssue = dbIssue ;
349
374
350
375
// if the issue has payment success or payment pending status, we'll ignore this process.
@@ -633,6 +658,15 @@ async function handleIssueUnAssignment(event, issue) {
633
658
let dbIssue ;
634
659
try {
635
660
dbIssue = await ensureChallengeExists ( event , issue ) ;
661
+
662
+ if ( ! dbIssue ) {
663
+ const err = errors . internalDependencyError ( `Can't find the issue in DB. It's not found or not accessible` ) ;
664
+ // The dbissue is not found, the db is not accessible, or the issue is still in creation process.
665
+ // Handle it for rescheduling.
666
+ await eventService . handleEventGracefully ( event , issue , err ) ;
667
+ return ;
668
+ }
669
+
636
670
if ( dbIssue . assignee ) {
637
671
const assigneeUserId = gitHelper . getUserIdByLogin ( event , dbIssue . assignee ) ;
638
672
logger . debug ( `Looking up TC handle of git user: ${ assigneeUserId } ` ) ;
0 commit comments