question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StepFunction: inputPath, resultPath, outputPath should be nullable

See original GitHub issue

Ref: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-input-output-processing.html

  • 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: image

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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zarakaycommented, Feb 20, 2019

could also define the type of inputPath, resultPath and outputPath to include DISCARD, eg:

type Foo = string | 'DISCARD'

Might provide some good type hints in the IDE to the special value case

0reactions
github-actions[bot]commented, Jun 18, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

inputPath, resultPath, outputPath should be nullable · ...
Looking at the TaskProps ( deploy/node_modules/@aws-cdk/aws-stepfunctions/lib/states/task.d.ts ) it seems these are defined as follows: /** * ...
Read more >
ResultPath - AWS Step Functions
Using "ResultPath": null , the state's input payload will be copied directly to the output, with no regard for the result. The following...
Read more >
AWS step function: how to pass InputPath to OutputPath ...
1 Answer 1 ·... InputPath specifies what part of A is handed to your task ·... ResultPath specifies where in A to put...
Read more >
[Handbook] AWS Step Functions Input and Output Manipulation
InputPath, OutputPath, ResultPath, Parameters, and ResultSelector, will manipulate JSON as it goes through every state within your workflow.
Read more >
AWS Step Functions: JSONPath data processing - YouTube
JSONPath is introduced, and the InputPath, OutputPath, ResultPath, ... and the effects of null on different fields are presented.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found