File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -2282,6 +2282,9 @@ function sanitizeData(data, challenge) {
2282
2282
*/
2283
2283
async function deleteChallenge ( currentUser , challengeId ) {
2284
2284
const challenge = await challengeDomain . lookup ( getLookupCriteria ( "id" , challengeId ) ) ;
2285
+ if ( ! challenge ) {
2286
+ throw new errors . NotFoundError ( `Challenge with id: ${ challengeId } doesn't exist` ) ;
2287
+ }
2285
2288
if ( challenge . status !== constants . challengeStatuses . New ) {
2286
2289
throw new errors . BadRequestError (
2287
2290
`Challenge with status other than "${ constants . challengeStatuses . New } " cannot be removed`
@@ -2292,7 +2295,10 @@ async function deleteChallenge(currentUser, challengeId) {
2292
2295
// check if user are allowed to delete the challenge
2293
2296
await ensureAccessibleForChallenge ( currentUser , challenge ) ;
2294
2297
// delete DB record
2295
- await challengeDomain . delete ( getLookupCriteria ( "id" , challengeId ) ) ;
2298
+ const { items } = await challengeDomain . delete ( getLookupCriteria ( "id" , challengeId ) ) ;
2299
+ if ( ! _ . find ( items , { id : challengeId } ) ) {
2300
+ throw new errors . Internal ( `There was an error deleting the challenge with id: ${ challengeId } from dynamo` ) ;
2301
+ }
2296
2302
// delete ES document
2297
2303
await esClient . delete ( {
2298
2304
index : config . get ( "ES.ES_INDEX" ) ,
You can’t perform that action at this time.
0 commit comments