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

bug: 'Invalid State Machine Definition' when 'if' condition checks for array existence and length #904

Open
dmeehan1968 opened this issue Oct 23, 2023 · 0 comments

Comments

@dmeehan1968
Copy link

Reading message from an SQS Queue, the response.Message property can be undefined, so its normal to check as defined. The length check isn't strictly necessary, and it works without, but the interesting thing is that the error message says "Expected value of type STRING" and "StringGreaterThan".

const main = asl.deploy.asStateMachine(async (input: SQSEvent) => {

    const response = await asl.sdk(SQS).receiveMessage({
        parameters: {
            QueueUrl: asl.deploy.getParameter('QUEUE_URL'),
            MaxNumberOfMessages: 1,
        }
    })

    if (response.Messages !== undefined && response.Messages.length > 0) {
        const messages = (response.Messages).map(message => asl.states.stringToJson(message.Body))

        // ...
    }

})

Full error:

InvalidDefinition: Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: Expected value of type [STRING] at /States/If (response.Messages !== .../Choices[0]/And[1]/StringGreaterThan'
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

1 participant