Describe the bug
The LambdaInvoke package allows for an addCatch which is documented as allowing a CatchProps to include a resultPath special value of DISCARD
/**
* JSONPath expression to indicate where to inject the error data
*
* May also be the special value DISCARD, which will cause the error
* data to be discarded.
*
* @default $
*/
readonly resultPath?: string;
HOWEVER, when trying to add a catch with this special value of DISCARD for the resultPath it tosses an error:
Error: Expected JSON path to start with '$', got: DISCARD
Trace: Error: Expected JSON path to start with '$', got: DISCARD
at renderJsonPath (node_modules/.pnpm/aws-cdk-lib@2.91.0_constructs@10.2.69/node_modules/aws-cdk-lib/aws-stepfunctions/lib/states/state.js:1:8225)
at renderCatch (node_modules/.pnpm/aws-cdk-lib@2.91.0_constructs@10.2.69/node_modules/aws-cdk-lib/aws-stepfunctions/lib/states/state.js:1:7612)
Expected Behavior
The step function definition should use the special null value as the resultPath when passed the special DISCARD value.
Current Behavior
Attempted deploy causes the CDK to fail during validation:
Error: Expected JSON path to start with '$', got: DISCARD
Trace: Error: Expected JSON path to start with '$', got: DISCARD
at renderJsonPath (node_modules/.pnpm/aws-cdk-lib@2.91.0_constructs@10.2.69/node_modules/aws-cdk-lib/aws-stepfunctions/lib/states/state.js:1:8225)
at renderCatch (node_modules/.pnpm/aws-cdk-lib@2.91.0_constructs@10.2.69/node_modules/aws-cdk-lib/aws-stepfunctions/lib/states/state.js:1:7612)
Reproduction Steps
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { LambdaInvoke } from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { DISCARD, StateMachine } from 'aws-cdk-lib/aws-stepfunctions';
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
export class SampleAppStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const taskA = new LambdaInvoke(this, 'taskA', {
resultPath: '$.Payload',
lambdaFunction: new Function(this, 'taskAFnc', {
runtime: Runtime.NODEJS_18_X,
code: Code.fromInline('exports.handler = async () => { throw new Error("Error"); };'),
handler: 'index.handler',
}),
});
const taskB = new LambdaInvoke(this, 'taskB', {
resultPath: '$.Payload',
lambdaFunction: new Function(this, 'taskBFnc', {
runtime: Runtime.NODEJS_18_X,
code: Code.fromInline('exports.handler = async () => "OK";'),
handler: 'index.handler',
}),
});
taskA.addCatch(taskB, {
resultPath: DISCARD,
});
const stateMachine = new StateMachine(this, 'SimpleStateMachine', {
definition: taskA,
});
}
}
then run cdk synth
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.91.0 (build eea12ea)
Framework Version
No response
Node.js Version
v18.17.0
OS
Darwin razorcrest.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:23 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6020 arm64
Language
Typescript
Language Version
TypeScript (5.1.6)
Other information
No response
Describe the bug
The LambdaInvoke package allows for an
addCatchwhich is documented as allowing aCatchPropsto include aresultPathspecial value ofDISCARDHOWEVER, when trying to add a catch with this special value of
DISCARDfor theresultPathit tosses an error:Expected Behavior
The step function definition should use the special
nullvalue as the resultPath when passed the specialDISCARDvalue.Current Behavior
Attempted deploy causes the CDK to fail during validation:
Reproduction Steps
then run
cdk synthPossible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.91.0 (build eea12ea)
Framework Version
No response
Node.js Version
v18.17.0
OS
Darwin razorcrest.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:23 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6020 arm64
Language
Typescript
Language Version
TypeScript (5.1.6)
Other information
No response