From 0429d37860f633725ecff6bd923e196a61121881 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Fri, 19 Feb 2021 17:28:20 -0300 Subject: [PATCH] 17319: Throws exceptions when attempting to use "" as uuid on service calls. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/services/common-service/common-service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts index 8e00c4ad..54c0edf6 100644 --- a/src/services/common-service/common-service.ts +++ b/src/services/common-service/common-service.ts @@ -68,6 +68,12 @@ export class CommonService { } } + private validateUuid(uuid: string) { + if (uuid === "") { + throw new Error('UUID cannot be empty string'); + } + } + static defaultResponse(promise: AxiosPromise, actions: ApiActions, mapKeys = true, showErrors = true): Promise { const reqId = uuid(); actions.progressFn(reqId, true); @@ -97,6 +103,7 @@ export class CommonService { } delete(uuid: string): Promise { + this.validateUuid(uuid); return CommonService.defaultResponse( this.serverApi .delete(this.resourceType + '/' + uuid), @@ -105,6 +112,7 @@ export class CommonService { } get(uuid: string, showErrors?: boolean) { + this.validateUuid(uuid); return CommonService.defaultResponse( this.serverApi .get(this.resourceType + '/' + uuid), @@ -148,6 +156,7 @@ export class CommonService { } update(uuid: string, data: Partial) { + this.validateUuid(uuid); return CommonService.defaultResponse( this.serverApi .put(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)), -- 2.30.2