Skip to content

Conditional check for null equality works in normal flow but fails unit test with internal server error #1548

Description

@Reisclef

Azure Logic Apps (Standard) 5.961.19
Microsoft.Azure.Workflows.WebJobs.Tests.Extension 1.0.3

Describe the Bug

When unit testing a workflow containing a null equality check for an object variable, the test will fail stating an internal server error with no other details.

Plan Type

Local

Steps to Reproduce the Bug or Issue

  1. Create an HTTP workflow with an object variable, and a conditional check for the variable to equal null
  2. Run workflow and observe success
  3. Create a basic unit test to check for success
  4. Observe that the unit test fails

Workflow JSON

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "actions": {
            "Initialize_variables": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "PossiblyNullObject",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {}
            },
            "test_Resp": {
                "type": "Response",
                "kind": "Http",
                "inputs": {
                    "statusCode": 200
                },
                "runAfter": {
                    "Condition": [
                        "SUCCEEDED"
                    ]
                },
                "operationOptions": "Asynchronous"
            },
            "Condition": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('PossiblyNullObject')",
                                "@null"
                            ]
                        }
                    ]
                },
                "actions": {},
                "else": {
                    "actions": {}
                },
                "runAfter": {
                    "Initialize_variables": [
                        "SUCCEEDED"
                    ]
                }
            }
        },
        "outputs": {},
        "triggers": {
            "test_req": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "method": "GET",
                    "schema": {}
                }
            }
        }
    },
    "kind": "Stateful"
}

Screenshots or Videos

No response

Additional context

[TestMethod]
public async Task Test_PossiblyNullObjectCondition_WorkflowSucceeds()
{
    var triggerMock = new TriggerMock(status: TestWorkflowStatus.Succeeded, name: "test_req", outputs: (MockOutput)null);

    var testRun = await this.TestExecutor.Create()
                .RunWorkflowAsync(testMock: new TestMockDefinition(
                    triggerMock: triggerMock,
                    actionMocks: new Dictionary<string, ActionMock>()))
                .ConfigureAwait(false);

    Assert.IsNotNull(testRun);
    Assert.AreEqual(TestWorkflowStatus.Succeeded, testRun.Status);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions