StepFunction: inputPath, resultPath, outputPath should be nullable
See original GitHub issue
- The InputPath field selects a portion of the state’s input to pass to the state’s task for processing. If you omit the field, it gets the $ value, representing the entire input. If you use null, the input is discarded…
- If the ResultPath is null, the results of executing the state are discarded and the input is untouched.
- If the OutputPath is null, JSON text representing an empty object {} is sent to the next state.
Looking at the TaskProps
(deploy/node_modules/@aws-cdk/aws-stepfunctions/lib/states/task.d.ts
) it seems these are defined as follows:
/**
* JSONPath expression to select part of the state to be the input to this state.
*
* May also be the special value DISCARD, which will cause the effective
* input to be the empty object {}.
*
* @default $
*/
inputPath?: string;
/**
* JSONPath expression to select part of the state to be the output to this state.
*
* May also be the special value DISCARD, which will cause the effective
* output to be the empty object {}.
*
* @default $
*/
outputPath?: string;
/**
* JSONPath expression to indicate where to inject the state's output
*
* May also be the special value DISCARD, which will cause the state's
* input to become its output.
*
* @default $
*/
resultPath?: string;
While obviously, in finding this, I can see that the special value DISCARD
can be used… though this doesn’t seem obvious compared to all of the standard docs saying these fields can be set to null
.
If I try to set it to null
, typescript complains:
Since strictNullChecks
is set in the default TypeScript config, this could be implemented as a Union type such as string | null
as per https://www.typescriptlang.org/docs/handbook/advanced-types.html#nullable-types
I’m guessing perhaps you chose not to do that though, since an end user could change strictNullTypes
, at which point it would no longer work as expected…
Maybe some other enum sort of type would be useful here? So that it is obvious from the types that there is a way to make it discard the values (since the defaults are to include everything)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top GitHub Comments
could also define the type of
inputPath
,resultPath
andoutputPath
to includeDISCARD
, eg:type Foo = string | 'DISCARD'
Might provide some good type hints in the IDE to the special value case
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.