Description
Describe the bug
When a Map.jsonata()
state uses itemProcessor()
with a tasks.LambdaInvoke
inside it, the CDK (tested with v2.134.0) synthesises invalid ASL.
At the map level it emits
"ProcessorConfig": { "Mode": "ITEM_PROCESSOR", "QueryLanguage": "JSONata" }
but the generated LambdaInvoke
child state still contains a Parameters
block.
The Step Functions schema forbids mixing those two worlds: the JSONPath‑style fields (InputPath
, Parameters
, ResultSelector
, …) are not allowed in a state (or workflow) whose QueryLanguage
is JSONata
.
As a result the service rejects the template with
SCHEMA_VALIDATION_FAILED: The QueryLanguage is set to 'JSONata',
but field 'Parameters' is only supported for the 'JSONPath' QueryLanguage …
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
CDK should produce ASL that passes Step Functions validation.
Either
- remove the
Parameters
field and emitArguments
/Output
(JSONata‑style), or - fall back to
QueryLanguage: JSONPath
for theLambdaInvoke
state (which is afaik not possible ifqueryLanguage
has been set on the whole step function).
Deployment should succeed and the state machine should execute.
Current Behavior
cdk deploy
(or CloudFormation update) fails with UPDATE_FAILED
on the AWS::StepFunctions::StateMachine
resource. The error is exactly the one quoted above, and the stack rolls back.
Reproduction Steps
The snippet below can be copied into a fresh CDK v2 TypeScript app and deployed; nothing except aws-cdk-lib
and constructs
is required.
// file: lib/bug-stack.ts
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
export class BugStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// dummy Lambda – returns its input
const fn = new lambda.Function(this, 'Fn', {
runtime: lambda.Runtime.NODEJS_18_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = e => e;'),
});
// 1) MAP in ITEM_PROCESSOR mode + JSONata
const map = sfn.Map.jsonata(this, 'Map', {
items: sfn.ProvideItems.jsonata('{% [ { "foo": "bar" } ] %}'),
});
// 2) little Pass to prove Pass works fine
const pass = new sfn.Pass.jsonata(this, 'Pass', {
outputs: '{% $states.input %}',
});
// 3) LambdaInvoke – this is the problematic state
const invoke = new tasks.LambdaInvoke(this, 'Invoke', {
lambdaFunction: fn,
payload: sfn.TaskInput.fromObject({
foo: '{% $states.input.foo %}',
}),
});
// assemble the iterator
map.itemProcessor(pass.next(invoke));
// top‑level state‑machine, JSONata turned on
new sfn.StateMachine(this, 'StateMachine', {
definitionBody: sfn.DefinitionBody.fromChainable(map),
queryLanguage: sfn.QueryLanguage.JSONATA,
});
}
}
How to run
# 1. create a new project
npx cdk@2 init app --language typescript
npm i aws-cdk-lib constructs
# 2. replace lib/<app>-stack.ts with the file above
npm run build
cdk deploy # fails with SCHEMA_VALIDATION_FAILED
What you should see
Invalid State Machine Definition:
SCHEMA_VALIDATION_FAILED: The QueryLanguage is set to 'JSONata',
but field 'Parameters' is only supported for the 'JSONPath' QueryLanguage
at /States/Map/ItemProcessor/States/Invoke/Resource
Removing the LambdaInvoke
or removing queryLanguage
from the StateMachine
and setting it per state (and using Map.jsonPath
) makes the deployment succeed, which confirms the issue is confined to LambdaInvoke
inside an itemProcessor
in JSONata mode.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.1013.0
Framework Version
No response
Node.js Version
v22.14.0
OS
macOS 15.4.1
Language
TypeScript
Language Version
TypeScript 5.6.3
Other information
No response