From 5f0b865a87707e2c5fc6759a104f0cfadbe0501d Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Wed, 27 Dec 2023 15:40:30 -0800 Subject: [PATCH] address minor comments Signed-off-by: Jackie Han --- .../flowframework/model/WorkflowStepValidator.java | 2 +- .../workflow/WorkflowProcessSorter.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/model/WorkflowStepValidator.java b/src/main/java/org/opensearch/flowframework/model/WorkflowStepValidator.java index 001ccd816..cc0da5b6c 100644 --- a/src/main/java/org/opensearch/flowframework/model/WorkflowStepValidator.java +++ b/src/main/java/org/opensearch/flowframework/model/WorkflowStepValidator.java @@ -95,7 +95,7 @@ public static WorkflowStepValidator parse(XContentParser parser) throws IOExcept try { timeout = TimeValue.parseTimeValue(parser.text(), TIMEOUT); } catch (IllegalArgumentException e) { - logger.error("Failed to parse TIMEOUT value for field [" + fieldName + "]", e); + logger.error("Failed to parse TIMEOUT value for field [{}]", fieldName, e); throw new FlowFrameworkException( "Failed to parse workflow-step.json file for field [" + fieldName + "]", RestStatus.INTERNAL_SERVER_ERROR diff --git a/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java b/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java index 64b6d2e68..bb1334470 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java +++ b/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java @@ -141,7 +141,7 @@ public List sortProcessNodes(Workflow workflow, String workflowId) * @throws Exception if validation fails */ public void validate(List processNodes) throws Exception { - WorkflowValidator validator = readWorkflowValidator(processNodes.get(0).id()); + WorkflowValidator validator = readWorkflowValidator(); validatePluginsInstalled(processNodes, validator); validateGraph(processNodes, validator); } @@ -246,13 +246,13 @@ public void validateGraph(List processNodes, WorkflowValidator vali } } - private WorkflowValidator readWorkflowValidator(String workflowId) { + private WorkflowValidator readWorkflowValidator() { try { return WorkflowValidator.parse("mappings/workflow-steps.json"); } catch (Exception e) { - logger.error("Failed to read workflow-steps mapping file", e); + logger.error("Failed at reading workflow-steps mapping file", e); throw new FlowFrameworkException( - "Workflow " + workflowId + " failed at reading workflow-steps mapping file", + "Failed at reading workflow-steps.json mapping file for a new workflow.", RestStatus.INTERNAL_SERVER_ERROR ); } @@ -262,11 +262,11 @@ private WorkflowValidator readWorkflowValidator(String workflowId) { * A method for parsing workflow timeout value. * The value could be parsed from node NODE_TIMEOUT_FIELD, the timeout field in workflow-step.json, * or the default NODE_TIMEOUT_DEFAULT_VALUE - * @param node the workflow nde + * @param node the workflow node * @return the timeout value */ protected TimeValue parseTimeout(WorkflowNode node) { - WorkflowValidator validator = readWorkflowValidator(node.id()); + WorkflowValidator validator = readWorkflowValidator(); TimeValue nodeTimeoutValue = Optional.ofNullable(validator.getWorkflowStepValidators().get(node.type()).getTimeout()) .orElse(NODE_TIMEOUT_DEFAULT_VALUE); String nodeTimeoutAsString = nodeTimeoutValue.getSeconds() + "s";