Merge branch 'master' into 16848-token-handling-improvements
[arvados-workbench2.git] / src / services / common-service / common-service.ts
index 48fcb06dd027c786791afc29bb3d4536890d4a3a..e43f9f8f136a7404af40b9ffb0626cffd650d9ad 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);
@@ -99,6 +105,7 @@ export class CommonService<T> {
     }
 
     delete(uuid: string): Promise<T> {
+        this.validateUuid(uuid);
         return CommonService.defaultResponse(
             this.serverApi
                 .delete(this.resourceType + '/' + uuid),
@@ -107,6 +114,7 @@ export class CommonService<T> {
     }
 
     get(uuid: string, showErrors?: boolean) {
+        this.validateUuid(uuid);
         return CommonService.defaultResponse(
             this.serverApi
                 .get<T>(this.resourceType + '/' + uuid),
@@ -150,6 +158,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)),