Severity
P3 - Medium (Minor functionality affected)
Describe the Bug with repro steps
Unit-testing SDK throws on workflows that Terminate with a custom (non-enum) error code
Summary
UnitTestExecutor.RunWorkflowAsync throws System.ArgumentException: Requested value '<code>' was not found. instead of returning a Failed TestWorkflowRun whenever the workflow run ends with a runError.code (or an action error code) that is not a member of the ErrorResponseCode enum.
Custom Terminate error codes are valid at runtime in Logic Apps Standard (the code field is a free-form string), so this makes it impossible to unit-test any error/Catch path that terminates with a domain-specific code.
Repro
-
Author a Stateful workflow with a Try/Catch pattern whose Catch terminates the run:
"Terminate_-_Failed": {
"type": "Terminate",
"inputs": {
"runStatus": "Failed",
"runError": {
"code": "@variables('ErrorCode')",
"message": "@variables('ErrorMessage')"
}
}
}
where ErrorCode resolves to a custom string, e.g. "PublisherDeliveryFailed_APICallFailed".
-
Mock the actions so the run reaches Terminate_-_Failed, then:
var run = await executor.Create().RunWorkflowAsync(testMock: mockData);
What type of Logic App Is this happening in?
Standard (VSCode)
Are you experiencing a regression?
No response
Which operating system are you using?
Windows
Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg
Yes
Workflow JSON
Screenshots or Videos
No response
Environment
- Package:
Microsoft.Azure.Workflows.WebJobs.Tests.Extension 1.0.3 (latest on NuGet)
- Target framework:
net8.0
- Test framework: MSTest
Additional context
Requested value 'PublisherDeliveryFailed_APICallFailed' was not found.
at Microsoft.Azure.Workflows.UnitTesting.TestHost.UnitTestEngine.ExecuteWorkflow(FlowPropertiesDefinition workflowDefinition, TriggerMock triggerMock, Dictionary`2 actionMocks, String appDirectory, String connections, String parameters, IDictionary`2 localSettings, String customCodeFunctionFilePath, Int32 timeoutInSeconds)
at Microsoft.Azure.Workflows.UnitTesting.TestHost.UnitTestEngine.ExecuteWorkflow(FlowPropertiesDefinition workflowDefinition, TriggerMock triggerMock, Dictionary`2 actionMocks, String appDirectory, String connections, String parameters, IDictionary`2 localSettings, String customCodeFunctionFilePath, Int32 timeoutInSeconds)
at Microsoft.Azure.Workflows.UnitTesting.UnitTestExecutor.RunWorkflowAsync(TestMockDefinition testMock, Int32 timeoutInSeconds)
at Integration.Erp04.LogicApps.Tests.Failed_Run.RunAndCaptureAsync(String mockName) in C:\Repo\CHC.Integration.ERP\tests\erp04\Integration.Erp04.LogicApps\int22svc01p01-residentmovements-ecase-pub\Failed-Run\Failed-Run.cs:line 100
Severity
P3 - Medium (Minor functionality affected)
Describe the Bug with repro steps
Unit-testing SDK throws on workflows that Terminate with a custom (non-enum) error code
Summary
UnitTestExecutor.RunWorkflowAsyncthrowsSystem.ArgumentException: Requested value '<code>' was not found.instead of returning aFailedTestWorkflowRunwhenever the workflow run ends with arunError.code(or an action errorcode) that is not a member of theErrorResponseCodeenum.Custom
Terminateerror codes are valid at runtime in Logic Apps Standard (the code field is a free-form string), so this makes it impossible to unit-test any error/Catch path that terminates with a domain-specific code.Repro
Author a Stateful workflow with a Try/Catch pattern whose Catch terminates the run:
where
ErrorCoderesolves to a custom string, e.g."PublisherDeliveryFailed_APICallFailed".Mock the actions so the run reaches
Terminate_-_Failed, then:What type of Logic App Is this happening in?
Standard (VSCode)
Are you experiencing a regression?
No response
Which operating system are you using?
Windows
Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg
Yes
Workflow JSON
Screenshots or Videos
No response
Environment
Microsoft.Azure.Workflows.WebJobs.Tests.Extension1.0.3 (latest on NuGet)net8.0Additional context