From 49d6672cd9adf2363c4f6a1d9a05bce35a47833d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 9 Feb 2024 23:34:40 +0000 Subject: [PATCH] Ensure params are consumed before checking feature flag (#514) Signed-off-by: Daniel Widdis (cherry picked from commit 1727434f3b2b86091247622590f8da0fa531624d) Signed-off-by: github-actions[bot] --- .../flowframework/rest/RestCreateWorkflowAction.java | 4 ++-- .../flowframework/rest/RestGetWorkflowStateAction.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java index 54c485ec0..490f4f3ff 100644 --- a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java +++ b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java @@ -73,6 +73,8 @@ public List routes() { @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { String workflowId = request.param(WORKFLOW_ID); + String[] validation = request.paramAsStringArray(VALIDATION, new String[] { "all" }); + boolean provision = request.paramAsBoolean(PROVISION_WORKFLOW, false); if (!flowFrameworkSettings.isFlowFrameworkEnabled()) { FlowFrameworkException ffe = new FlowFrameworkException( "This API is disabled. To enable it, set [" + FLOW_FRAMEWORK_ENABLED.getKey() + "] to true.", @@ -86,8 +88,6 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli XContentParser parser = request.contentParser(); ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser); Template template = Template.parse(parser); - String[] validation = request.paramAsStringArray(VALIDATION, new String[] { "all" }); - boolean provision = request.paramAsBoolean(PROVISION_WORKFLOW, false); WorkflowRequest workflowRequest = new WorkflowRequest(workflowId, template, validation, provision); diff --git a/src/main/java/org/opensearch/flowframework/rest/RestGetWorkflowStateAction.java b/src/main/java/org/opensearch/flowframework/rest/RestGetWorkflowStateAction.java index 9db927f34..ded82f92c 100644 --- a/src/main/java/org/opensearch/flowframework/rest/RestGetWorkflowStateAction.java +++ b/src/main/java/org/opensearch/flowframework/rest/RestGetWorkflowStateAction.java @@ -57,6 +57,7 @@ public String getName() { @Override protected BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { String workflowId = request.param(WORKFLOW_ID); + boolean all = request.paramAsBoolean("all", false); try { if (!flowFrameworkFeatureEnabledSetting.isFlowFrameworkEnabled()) { throw new FlowFrameworkException( @@ -75,7 +76,6 @@ protected BaseRestHandler.RestChannelConsumer prepareRequest(RestRequest request throw new FlowFrameworkException("workflow_id cannot be null", RestStatus.BAD_REQUEST); } - boolean all = request.paramAsBoolean("all", false); GetWorkflowStateRequest getWorkflowRequest = new GetWorkflowStateRequest(workflowId, all); return channel -> client.execute(GetWorkflowStateAction.INSTANCE, getWorkflowRequest, ActionListener.wrap(response -> { XContentBuilder builder = response.toXContent(channel.newBuilder(), ToXContent.EMPTY_PARAMS);