17319: Throws exceptions when attempting to use "" as uuid on service calls.
[arvados-workbench2.git] / src / services / common-service / common-service.ts
index 8e00c4ad1abd42897f84cc1634d34a22b5bd48f0..54c0edf6bf2c684346e0309103ad085c4f38a541 100644 (file)
@@ -68,6 +68,12 @@ export class CommonService<T> {
             }
         }
 
+    private validateUuid(uuid: string) {
+        if (uuid === "") {
+            throw new Error('UUID cannot be empty string');
+        }
+    }
+
     static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions, mapKeys = true, showErrors = true): Promise<R> {
         const reqId = uuid();
         actions.progressFn(reqId, true);
@@ -97,6 +103,7 @@ export class CommonService<T> {
     }
 
     delete(uuid: string): Promise<T> {
+        this.validateUuid(uuid);
         return CommonService.defaultResponse(
             this.serverApi
                 .delete(this.resourceType + '/' + uuid),
@@ -105,6 +112,7 @@ export class CommonService<T> {
     }
 
     get(uuid: string, showErrors?: boolean) {
+        this.validateUuid(uuid);
         return CommonService.defaultResponse(
             this.serverApi
                 .get<T>(this.resourceType + '/' + uuid),
@@ -148,6 +156,7 @@ export class CommonService<T> {
     }
 
     update(uuid: string, data: Partial<T>) {
+        this.validateUuid(uuid);
         return CommonService.defaultResponse(
             this.serverApi
                 .put<T>(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)),