diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 9f1d9991b1..a4e9c8d422 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -12,6 +12,7 @@ import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.Schedule; import io.metersphere.commons.constants.*; +import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.ResetOrderRequest; @@ -373,12 +374,22 @@ public class ApiAutomationController { @PostMapping(value = "/checkScenarioEnv") public boolean checkScenarioEnv(@RequestBody ApiScenarioWithBLOBs request) { - return apiAutomationService.checkScenarioEnv(request); + try { + return apiAutomationService.checkScenarioEnv(request); + } catch (Exception e) { + MSException.throwException("场景步骤解析错误,检查是否包含插件步骤!"); + } + return false; } @GetMapping(value = "/checkScenarioEnv/{scenarioId}") public boolean checkScenarioEnvByScenarioId(@PathVariable String scenarioId) { - return apiAutomationService.checkScenarioEnv(scenarioId); + try { + return apiAutomationService.checkScenarioEnv(scenarioId); + } catch (Exception e) { + MSException.throwException("场景步骤解析错误,检查是否包含插件步骤!"); + } + return false; } @GetMapping("/follow/{scenarioId}") diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 914f06adc2..14144aa7ef 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -347,8 +347,11 @@ public class ElementUtil { public static void dataFormatting(JSONArray hashTree) { for (int i = 0; i < hashTree.size(); i++) { JSONObject element = hashTree.getJSONObject(i); + if (element == null) { + continue; + } formatSampler(element); - if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) { + if (element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) { element.fluentPut("clazzName", clazzMap.get(element.getString("type"))); } if (element.containsKey("hashTree")) { diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java index e3864996d3..fd76f76075 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioEnvService.java @@ -311,7 +311,7 @@ public class ApiScenarioEnvService { builder.append(apiScenarioWithBLOBs.getName()).append("; "); } } catch (Exception e) { - MSException.throwException("场景:" + builder.toString() + "运行环境未配置,请检查!"); + MSException.throwException("场景:" +apiScenarioWithBLOBs.getName() +",步骤解析错误,检查是否包含插件步骤!"); } } if (builder.length() > 0) {