Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when adding "produceEvents" to the workflow definition #358

Closed
brampurnot opened this issue Nov 21, 2023 · 4 comments
Closed

Error when adding "produceEvents" to the workflow definition #358

brampurnot opened this issue Nov 21, 2023 · 4 comments

Comments

@brampurnot
Copy link

brampurnot commented Nov 21, 2023

Hi all!

I have the following simple workflow definition:

    "id": "655bc96b9e3a30b2ba450a38",
    "name": "test",
    "version": "1.0.0",
    "description": "test",
    "specVersion": "0.8",
    "start": {
        "stateName": "SendEmail-c25c5297-8466-452f-9210-ca4d51abe48e",
        "schedule": {}
    },
    "states": [
        {
            "name": "SendEmail-c25c5297-8466-452f-9210-ca4d51abe48e",
            "type": "operation",
            "actions": [
                {
                    "actionDataFilter": {
                        "results": "${ {data: .sendEmail.data, status: .sendEmail.status} }",
                        "toStateData": "${ .finalData }"
                    },
                    "name": "CallEmailActivity",
                    "functionRef": {
                        "refName": "EmailActivity",
                        "arguments": {
                            "from": "someemail@gmail.com",
                            "to": "tosomeemail@gmail.com",
                            "subject": "Test",
                            "text": "Test email",
                            "tenant": "test-tenant",
                            "user": "tosomeemail@gmail.com",
                            "region": "eu-central-1",
                            "uniqueId": "${ $WORKFLOW.workflow.instanceId }"
                        },
                        "selectionSet": "{ status, data }"
                    }
                }
            ],
            "end": {
                "terminate": true,
                "produceEvents": [
                    {
                        "eventRef": "workflowCompleteEvent"
                    }
                ]
            },
            "stateDataFilter": {
                "output": "${ .finalData }"
            }
        }
    ],
    "functions": [
        {
            "type": "graphql",
            "name": "EmailActivity",
            "operation": "http://somegraphqlendpoint:4000/graphql#mutation#sendEmail"
        }
    ],
    "events": [
        {
            "kind": "produced",
            "name": "workflowCompleteEvent",
            "type": "wokrflow-completed"
        }
    ]
}

I'm actually trying to get an event to be produced at the end of the flow. When I load this into the webUI, it saves the workflow definition but it removes the "produceEvents" part. When I try to post it to the HTTP endpoint, I'm getting an HTTP 500 with the following error message:

      '   at Neuroglia.Mediation.Mediator.ExecuteAsync[TResult](IRequest`1 request, CancellationToken cancellationToken)\n' +
      '   at Synapse.Apis.Management.Http.Controllers.V1WorkflowsController.CreateWorkflow(V1CreateWorkflowCommand command, CancellationToken cancellationToken) in /src/src/apis/management/Synapse.Apis.Management.Http/Controllers/V1WorkflowsController.cs:line 53\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\n' +
      '--- End of stack trace from previous location ---\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\n' +
      '   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\n' +
      '   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\n' +
      '   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)\n' +
      '   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)\n' +
      '   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\n' +
      '   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\n' +
      '   at Microsoft.AspNetCore.OData.Routing.ODataRouteDebugMiddleware.Invoke(HttpContext context)\n' +
      '   at Neuroglia.Eventing.CloudEventMiddleware.InvokeAsync(HttpContext context, CloudEventFormatter formatter, ISubject`1 stream)\n' +
      '   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)\n' +

I get the latest version of Synapse deployed in Kubernetes. Any help would be appreciated!

Bram

@Lellson
Copy link

Lellson commented May 23, 2024

Hi, are there any updates regarding this issue? I am facing the exact same problem.

In the logs I also get the error message:
Newtonsoft.Json.JsonReaderException: Error reading boolean. Unexpected token: StartObject. Path '', line 31, position 20.

So I am guessing this serverless workflow feature is not implemented and we can currently not produce events if the workflow ends?

The same also applies to produceEvents inside transition.

Any help would be appreciated!

@cdavernas
Copy link
Member

So I am guessing this serverless workflow feature is not implemented and we can currently not produce events if the workflow ends?

It is implemented, but a bug was introduced, thus causing this issue. I spent the time working on DSL/runtime refactor and could therefore not address that one. All help is however warmly welcome!

@cdavernas
Copy link
Member

cdavernas commented May 23, 2024

On a site note, this bug does not apply to pending #366: Newtonsoft has been dropped in favor of System.Text.Json.

Said version is however a total overhaul, of both the DSL and all implementations (see https://github.com/serverlessworkflow/specification/releases/tag/v1.0.0-alpha1 for more information)

@cdavernas
Copy link
Member

Closed as should/does not apply to #366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants