Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stepfunctions): renderObject ignores explicit null #17098

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class RunGlueJobTask implements sfn.IStepFunctionsTask {
}

public bind(task: sfn.Task): sfn.StepFunctionsTaskConfig {
const notificationProperty = this.props.notifyDelayAfter ? { NotifyDelayAfter: this.props.notifyDelayAfter.toMinutes() } : null;
const notificationProperty = this.props.notifyDelayAfter ? { NotifyDelayAfter: this.props.notifyDelayAfter.toMinutes() } : undefined;
kaizencc marked this conversation as resolved.
Show resolved Hide resolved
let iamActions: string[] | undefined;
if (this.integrationPattern === sfn.ServiceIntegrationPattern.FIRE_AND_FORGET) {
iamActions = ['glue:StartJobRun'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class GlueStartJobRun extends sfn.TaskStateBase {
* @internal
*/
protected _renderTask(): any {
const notificationProperty = this.props.notifyDelayAfter ? { NotifyDelayAfter: this.props.notifyDelayAfter.toMinutes() } : null;
const notificationProperty = this.props.notifyDelayAfter ? { NotifyDelayAfter: this.props.notifyDelayAfter.toMinutes() } : undefined;
return {
Resource: integrationResourceArn('glue', 'startJobRun', this.integrationPattern),
Parameters: sfn.FieldUtils.renderObject({
Expand Down
17 changes: 16 additions & 1 deletion packages/@aws-cdk/aws-stepfunctions/lib/private/json-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function renderObject(obj: object | undefined): object | undefined {
handleNumber: renderNumber,
handleBoolean: renderBoolean,
handleResolvable: renderResolvable,
handleNull: renderNull,
});
}

Expand Down Expand Up @@ -81,6 +82,10 @@ export function findReferencedPaths(obj: object | undefined): Set<string> {
}
return {};
},

handleNull(_key: string, _x: null) {
return {};
},
});

return found;
Expand Down Expand Up @@ -124,6 +129,7 @@ interface FieldHandlers {
handleNumber(key: string, x: number): {[key: string]: number | string};
handleBoolean(key: string, x: boolean): {[key: string]: boolean};
handleResolvable(key: string, x: IResolvable): {[key: string]: any};
handleNull(key: string, x: null): {[key: string]: null};
}

export function recurseObject(obj: object | undefined, handlers: FieldHandlers, visited: object[] = []): object | undefined {
Expand All @@ -150,7 +156,9 @@ export function recurseObject(obj: object | undefined, handlers: FieldHandlers,
Object.assign(ret, recurseArray(key, value, handlers, visited));
} else if (typeof value === 'boolean') {
Object.assign(ret, handlers.handleBoolean(key, value));
} else if (value === null || value === undefined) {
} else if (value === null) {
Object.assign(ret, handlers.handleNull(key, value));
} else if (value === undefined) {
// Nothing
} else if (typeof value === 'object') {
if (Tokenization.isResolvable(value)) {
Expand Down Expand Up @@ -265,6 +273,13 @@ function renderBoolean(key: string, value: boolean): {[key: string]: boolean} {
return { [key]: value };
}

/**
* Render a parameter null value
*/
function renderNull(key: string, _value: null): {[key: string]: null} {
return { [key]: null };
}

/**
* If the indicated string is an encoded JSON path, return the path
*
Expand Down
15 changes: 15 additions & 0 deletions packages/@aws-cdk/aws-stepfunctions/test/fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ describe('Fields', () => {
},
});
});

test('null value rendered', () => {
const object = {
nullParameter: null,
};
expect(FieldUtils.renderObject(
{
reference1: object,
},
)).toStrictEqual({
reference1: {
nullParameter: null,
},
});
});
});

describe('intrinsics constructors', () => {
Expand Down