Description
Describe the bug
I want to define the arraySize
, which is currently of type number
, using a field in the task input. It is possible to use a JsonPath expression while still satisfying type-check by using JsonPath.numberAt()
arraySize: JsonPath.numberAt('$.fspArrayBatchSize'),
But there doesn't seem to be a way to do the same when using a JSONata expression.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
A JSONata expression equivalent to above JsonPath expression should also work.
arraySize: '{% $states.input.fspArrayBatchSize %}'),
Current Behavior
The following code throws compilation error since the JSONata expression is of type string whereas the construct is expecting a number for arraySize
.
arraySize: '{% $states.input.fspArrayBatchSize %}'),
Reproduction Steps
Try creating a Batch job task like below
aws_stepfunctions_tasks.BatchSubmitJob.jsonata(this, 'FSPBatchJob', {
jobName: props.fsp.batchJobName,
jobDefinitionArn: props.fsp.batchJobName,
jobQueueArn: props.fspBatchJobQueue.jobQueueArn,
arraySize: '{% $states.input.fspArrayBatchSize %}',
});
Possible Solution
Quick options I can think of:
- Convert
arraySize
to string but lose type check - Add a static method similar to JsonPath which satisfies type-check,
Jsonata.number('$states.input.fspArrayBatchSize')
Additional Information/Context
Workaround is to suppress type-check for that line. Verified by building, deploying and running a statemachine with below task.
aws_stepfunctions_tasks.BatchSubmitJob.jsonata(this, 'FSPBatchJob', {
jobName: props.fsp.batchJobName,
jobDefinitionArn: props.fsp.batchJobName,
jobQueueArn: props.fspBatchJobQueue.jobQueueArn,
// @ts-expect-error: CDK arraySize type is currently number
arraySize: '{% $states.input.fspArrayBatchSize %}',
});
CDK CLI Version
2.176.0 (build 899965d)
Framework Version
No response
Node.js Version
v20.17.0
OS
Mac Sequoia 15.4
Language
TypeScript
Language Version
5.0.4
Other information
No response