diff --git a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java index bf4943403..e88914cbb 100644 --- a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java +++ b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java @@ -78,18 +78,17 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli String workflowId = request.param(WORKFLOW_ID); String[] validation = request.paramAsStringArray(VALIDATION, new String[] { "all" }); boolean provision = request.paramAsBoolean(PROVISION_WORKFLOW, false); - final List validCreateParams = List.of(WORKFLOW_ID, VALIDATION, PROVISION_WORKFLOW); // If provisioning, consume all other params and pass to provision transport action Map params = provision ? request.params() .keySet() .stream() - .filter(k -> !validCreateParams.contains(k)) + .filter(k -> !request.consumedParams().contains(k)) .collect(Collectors.toMap(Function.identity(), request::param)) : request.params() .entrySet() .stream() - .filter(e -> !validCreateParams.contains(e.getKey())) + .filter(e -> !request.consumedParams().contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); if (!flowFrameworkSettings.isFlowFrameworkEnabled()) { FlowFrameworkException ffe = new FlowFrameworkException( @@ -105,7 +104,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli params.keySet().stream().forEach(request::param); request.content(); FlowFrameworkException ffe = new FlowFrameworkException( - "Only the parameters " + validCreateParams + " are permitted unless the provision parameter is set to true.", + "Only the parameters " + request.consumedParams() + " are permitted unless the provision parameter is set to true.", RestStatus.BAD_REQUEST ); return channel -> channel.sendResponse( diff --git a/src/test/java/org/opensearch/flowframework/rest/RestCreateWorkflowActionTests.java b/src/test/java/org/opensearch/flowframework/rest/RestCreateWorkflowActionTests.java index 1d99cf517..d95f10375 100644 --- a/src/test/java/org/opensearch/flowframework/rest/RestCreateWorkflowActionTests.java +++ b/src/test/java/org/opensearch/flowframework/rest/RestCreateWorkflowActionTests.java @@ -127,12 +127,7 @@ public void testCreateWorkflowRequestWithParamsButNoProvision() throws Exception createWorkflowRestAction.handleRequest(request, channel, nodeClient); assertEquals(RestStatus.BAD_REQUEST, channel.capturedResponse().status()); assertTrue( - channel.capturedResponse() - .content() - .utf8ToString() - .contains( - "Only the parameters [workflow_id, validation, provision] are permitted unless the provision parameter is set to true." - ) + channel.capturedResponse().content().utf8ToString().contains("are permitted unless the provision parameter is set to true.") ); }