Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 25, 2025

Fixes the Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: "=", near: "not_processed" error that occurs when using AWS DynamoDB locking features.

Problem

The MarkEventUnprocessed method in DynamoPersistenceProvider.cs was using incorrect DynamoDB UpdateExpression syntax:

UpdateExpression = "ADD not_processed = :n"

The ADD operation in DynamoDB does not use the = operator, causing the UpdateExpression to be invalid and throwing a syntax error during workflow execution.

Solution

Corrected the UpdateExpression syntax by removing the invalid = operator:

UpdateExpression = "ADD not_processed :n"

This follows the proper DynamoDB UpdateExpression syntax where ADD operations directly specify the attribute name followed by the value reference without an equals sign.

Impact

  • Resolves the DynamoDB syntax error when marking events as unprocessed
  • Fixes workflow execution failures when using UseAwsDynamoLocking configuration
  • No breaking changes or API modifications
  • Maintains backward compatibility

Closes issue where workflows would fail with DynamoDB UpdateExpression syntax errors during event processing.

Original prompt

This section details on the original issue you should resolve

<issue_title>Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: "=", near: "not_processed</issue_title>
<issue_description>Describe the bug
Sometimes during a workflow execution we see the following exception:
Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: "=", near: "not_processed

To Reproduce
use the following nuget versions:
WorkflowCore 3.6.2
WorkflowCore.Providers.AWS 3.6.0

happens after i configure: UseAwsDynamoLocking in startup.cs

Expected behavior
Should start the workflow

Additional context
Logs:
{"app":"MyApp","timestamp":"2024-11-12T11:52:22.7271646Z","message":"Starting step "WaitFor" on workflow "16f21c6f-4e4c-4636-a196-8d4dfe51234c"","level":"Debug","0":"WaitFor","1":"16f21c6f-4e4c-4636-a196-8d4dfe51234c","category":"WorkflowCore.Services.WorkflowExecutor","threadId":126,"version":"0.1.0+df7b726674aae621f4a6a7b477a91afb45072a98","logVersion":"2"}
{"app":"MyApp","timestamp":"2024-11-12T11:52:23.3639000Z","message":"Subscribing to event "operationCompletedEvent" "AlisTestingLockingZ3" for workflow "16f21c6f-4e4c-4636-a196-8d4dfe51234c" step 1","level":"Debug","0":"operationCompletedEvent","1":"AlisTestingLockingZ3","2":"16f21c6f-4e4c-4636-a196-8d4dfe51234c","3":1,"category":"WorkflowCore.Services.BackgroundTasks.WorkflowConsumer","threadId":77,"version":"0.1.0+df7b726674aae621f4a6a7b477a91afb45072a98","logVersion":"2"}

and then this error is thrown:

Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: "=", near: "not_processed = :n"\r\n ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.\r\n at Amazon.Runtime.HttpWebRequestMessage.ProcessHttpResponseMessage(HttpResponseMessage responseMessage)\r\n at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)\r\n at Amazon.Runtime.Internal.HttpHandler1.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n --- End of inner exception stack trace ---\r\n at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionStream(IRequestContext requestContext, IWebResponseData httpErrorResponse, HttpErrorResponseException exception, Stream responseStream)\r\n at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleExceptionAsync(IExecutionContext executionContext, HttpErrorResponseException exception)\r\n at Amazon.Runtime.Internal.ExceptionHandler1.HandleAsync(IExecutionContext executionContext, Exception exception)\r\n at Amazon.Runtime.Internal.ErrorHandler.ProcessExceptionAsync(IExecutionContext executionContext, Exception exception)\r\n at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.Signer.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at WorkflowCore.Providers.AWS.Services.DynamoPersistenceProvider.MarkEventUnprocessed(String id, CancellationToken cancellationToken)\r\n at WorkflowCore.Services.BackgroundTasks.WorkflowConsumer.SubscribeEvent(EventSubscription subscription, IPersistenceProvider persistenceStore, CancellationToken cancellationToken)\r\n at WorkflowCore.Services.BackgroundTasks.WorkflowConsumer.SubscribeEvent(EventSubscription subscription, IPersistenceProvider persistenceStore, CancellationToken cancellationToken)\r\n at WorkflowCore.Services.BackgroundTasks.WorkflowConsumer.ProcessItem(String itemId, Cancellation...

Fixes #1315

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: \"=\", near: \"not_processed Fix DynamoDB UpdateExpression syntax error in MarkEventUnprocessed method Sep 25, 2025
@Copilot Copilot AI requested a review from danielgerlag September 25, 2025 19:20
Copilot finished work on behalf of danielgerlag September 25, 2025 19:20
@danielgerlag danielgerlag marked this pull request as ready for review October 1, 2025 14:40
@danielgerlag danielgerlag requested a review from glucaci as a code owner October 1, 2025 14:40
@danielgerlag danielgerlag merged commit 5f934ab into master Oct 1, 2025
17 of 19 checks passed
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

Successfully merging this pull request may close these issues.

Amazon.DynamoDBv2.AmazonDynamoDBException: Invalid UpdateExpression: Syntax error; token: \"=\", near: \"not_processed
2 participants