aws_stepfunction_tasks: BatchSubmitJob task doesn't support JSONata expression for arraySize
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
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
```ts
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:
1. Convert `arraySize` to string but lose type check
2. 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.
```ts
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_
Contributor guide
Research direction
Start at the aws_stepfunctions_tasks.BatchSubmitJob.jsonata entry point and compare the arraySize typing with the JsonPath.numberAt() usage shown in the issue. Confirm the TypeScript compilation failure with the provided reproduction, then determine the smallest supported way for a JSONata expression to satisfy arraySize's numeric input type; done means the example compiles without a type suppression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100