WorkflowServer icon indicating copy to clipboard operation
WorkflowServer copied to clipboard

Bad request on executing activity

Open Vandevska-E opened this issue 1 year ago • 3 comments

Hi,

I am trying to configure an example of a schema and instance by using the Callback Api, and I am getting a bad request error. When I test via the callback swagger it is successful, but when I set an action on an activity i always get a bad request:

{"@t":"2025-02-18T14:51:13.5089705Z","@m":"Caught an exception","@i":"ebd50127","@l":"Error","ExceptionInfo":{"Exceptions":"(ProcessExecutionException)Create instance of the process, ProcessId=0e4f7da7-7089-1f89-42bb-aab55a1d4fd1, failed.\r\n->(ProcessExecutionException)Error while executing implementation of Activity activity of the process, ProcessId=0e4f7da7-7089-1f89-42bb-aab55a1d4fd1\r\n-->(CallbackException)Code: BadRequest. Requested url https://localhost:7143/api/workflowaction/executeaction.","Message":"Code: BadRequest. Requested url https://localhost:7143/api/workflowaction/executeaction.","StackTrace":" at OptimaJet.WorkflowServer.Callback.CallbackProvider.ExecuteActionInternalAsync(String name, ProcessInstance processInstance, String actionParameter) in /home/teamcity-agent/agent/work/a7a0351d523d7d93/OptimaJet.WorkflowServer/Callback/CallbackProvider.cs:line 515\r\n at OptimaJet.WorkflowServer.Callback.CallbackProvider.ExecuteActionAsync(String name, ProcessInstance processInstance, WorkflowRuntime runtime, String actionParameter, CancellationToken token) in /home/teamcity-agent/agent/work/a7a0351d523d7d93/OptimaJet.WorkflowServer/Callback/CallbackProvider.cs:line 147\r\n at OptimaJet.Workflow.Core.Runtime.AggregatingActionProvider.ExecuteActionAsync(String name, ProcessInstance processInstance, WorkflowRuntime runtime, String actionParameter, CancellationToken token)\r\n at OptimaJet.Workflow.Core.Execution.ActivityExecutor.ExecuteActionFromProviderAsync(ActionDefinitionReference method, ExecutionResponseComplete response, CancellationToken token)\r\n at OptimaJet.Workflow.Core.Execution.ActivityExecutor.ExecuteMethodAsync(ExecutionRequestParameters parameters, CancellationToken token)\r\n at OptimaJet.Workflow.Core.Execution.ActivityExecutor.ExecuteMethodAsyncWithHandling(ExecutionRequestParameters parameters)\r\n at OptimaJet.Workflow.Core.Execution.ActivityExecutor.ExecuteMethodAsyncWithHandling(ExecutionRequestParameters parameters)\r\n at OptimaJet.Workflow.Core.Execution.ActivityExecutor.TryExecuteAlwaysCondition()\r\n----------\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.ProcessErrorResponseAsync(ExecutionResponse response, ProcessInstance processInstance, CancellationToken token)\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.ExecuteFullAsync(ExecutionRequest executionRequest, CancellationToken token)\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.ExecuteCreatedProcessAsync(ProcessInstance processInstance, String identityId, String impersonatedIdentityId, CancellationToken token, ProcessInstancesTree processInstancesTree)\r\n----------\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.ExecuteCreatedProcessAsync(ProcessInstance processInstance, String identityId, String impersonatedIdentityId, CancellationToken token, ProcessInstancesTree processInstancesTree)\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.<>c__DisplayClass11_0.<<InitCreatedProcessAsync>b__1>d.MoveNext()\r\n--- End of stack trace from previous location ---\r\n at OptimaJet.Workflow.Core.Runtime.MultiThreadProcessExecutor.ExecuteAsync(WorkflowRuntime runtime, ProcessInstance processInstance, ProcessStatus status, TransitionDefinition executedTransition, Func`1 needNewThreadCheck, Func`2 action)\r\n at OptimaJet.Workflow.Core.Execution.ProcessExecutor.InitCreatedProcessAsync(String identityId, String impersonatedIdentityId, ProcessInstance processInstance, IDictionary`2 initialProcessParameters, CancellationToken token, ProcessInstancesTree processInstancesTree, TransitionDefinition startingTransition, List`1 persist)\r\n at OptimaJet.Workflow.Core.Runtime.WorkflowRuntime.CreateInstanceAsync(CreateInstanceParams createInstanceParams, CancellationToken token)\r\n at OptimaJet.WorkflowServer.ConfigApi.WorkflowProcessingAsync(WorkflowServerRuntime workflowServerRuntime, NameValueCollection form) in /home/teamcity-agent/agent/work/a7a0351d523d7d93/OptimaJet.WorkflowServer/ConfigApi.cs:line 1276\r\n at OptimaJet.WorkflowServer.ConfigApi.ConfigAPI(WorkflowServerRuntime workflowServerRuntime, HttpRequest request, NameValueCollection form, Stream filestream) in /home/teamcity-agent/agent/work/a7a0351d523d7d93/OptimaJet.WorkflowServer/ConfigApi.cs:line 199\r\n at OptimaJet.WorkflowServer.WorkflowServerRuntime.ConfigApiProcessingAsync(HttpRequest request) in /home/teamcity-agent/agent/work/a7a0351d523d7d93/OptimaJet.WorkflowServer/WorkflowServerRuntime.cs:line 1640"}}

I get the same issue regardless if I launch via Docker or not.

Any idea what could be the issue?

Vandevska-E avatar Feb 18 '25 14:02 Vandevska-E

Could you please provide the steps to reproduce it?

optimajet avatar Feb 19 '25 09:02 optimajet

I could reproduce it in 2 ways.

First way I tried: Step 1: Follow steps here to launch via docker: https://workflowserver.io/documentation/how-to-launch

Step 2: Here I tried 2 ways: 2A: I built my own API to connect to the Callback API. I configured it via the callback API page, tested the methods, and they were successful. 2B: I launched the WorkflowServer example callback API: https://github.com/optimajet/workflow-server-callback-api-example Again configured it via the callback API page, tested the methods, and they were successful.

Step 3: Create a schema with initial activity that transitions automatically to the 2nd activity on which one action was set (I chose one of the actions from my own api/ from the example api - which means the GET worked).

Step 4: Create an instance from that schema. Process is terminated due to the above mentioned error of bad request when executing the action.

Second way I tried: Step 1: Follow steps here to launch from GitHub: https://workflowserver.io/documentation/guides/how-to-build-workflow-server-from-github

Step 2: I built my own API to connect to the Callback API. I configured it via the callback API page, tested the methods, and they were successful.

Step 3: Create a schema with initial activity that transitions automatically to the 2nd activity on which one action was set (I chose one of the actions from my own api/ from the example api - which means the GET worked).

Step 4: Create an instance from that schema. Process is terminated due to the above mentioned error of bad request when executing the action.

In all of those cases I had the same error.

Vandevska-E avatar Feb 19 '25 12:02 Vandevska-E

Hi,

Thank you for the detailed report on the issue with the Callback API. Since you've already tested multiple setups and confirmed that the GET methods work correctly via the Callback API page, it seems the problem might be related to how the action is being executed within the workflow.

To help us diagnose the issue further, could you please provide the following additional details:

Action Code: Share the specific code or payload you are using for the action within the activity. This will help us understand how the action is structured and executed.

API Logs: If possible, share the logs from your Callback API when the action is triggered. This might reveal more specific details about what is causing the BadRequest error.

Schema Configuration: Provide the schema definition, especially the part where the action is set up. Knowing how the schema transitions and invokes the action will help us reproduce the issue accurately.

Workflow Server Version: Confirm the exact version of Workflow Server you are using.

Additional Information: Any other details that you believe might help us reproduce the issue would be greatly appreciated.

These details will allow us to dive deeper into the problem and hopefully identify the root cause.

Looking forward to your response.

Skluks avatar Feb 24 '25 11:02 Skluks