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): item batcher doesn't properly render json paths #29152

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Next Next commit
fix(stepfunctions): item batcher doesn't properly render json paths
The ItemBatcher property of DistributedMap supports json path fields,
but the new DistributedMap construct doesn't call
FieldUtils.renderObject when rendering the ItemBatcher.

Make sure to call `FieldUtils.renderObject()` when rendering this
property.

Added an integration test to ensure that the json path field resolves to
the actual value from the state in the input by checking the output from
the results writer in S3.
noseworthy committed Sep 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 27fff5df22731bd4bfc3494a11aa346289b8c509
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable no-console */

import {
S3Client,
ListObjectsV2Command,
GetObjectCommand,
} from '@aws-sdk/client-s3';

const client = new S3Client({});

type ResultObject ={
ExecutionArn: string;
Input: string;
InputDetails: { Included: boolean };
Name: string;
Output: string;
OutputDetails: { Included: boolean };
RedriveCount: number;
RedriveStatus: string;
RedriveStatusReason: string;
StartDate: string;
StateMachineArn: string;
Status: string;
StopDate: string;
};

export async function handler(event: { bucket: string; prefix: string }) {
console.log('handling event', event);

console.log('getting key for results writer succeeded file');
const listObjectsCommandOutput = await client.send(new ListObjectsV2Command({
Bucket: event.bucket,
Prefix: event.prefix,
}));

if (!listObjectsCommandOutput.Contents) {
throw new Error('No objects found');
}

const succeedKey = listObjectsCommandOutput.Contents.find((object) => object?.Key?.endsWith('SUCCEEDED_0.json'));

if (!succeedKey) {
throw new Error('No SUCCEEDED_0.json found');
}
console.log('found key', succeedKey.Key);

console.log('getting object');
const object = await client.send(new GetObjectCommand({
Bucket: event.bucket,
Key: succeedKey.Key,
}));

if (!object?.Body) {
throw new Error('No object body found');
}

const body: ResultObject[] = JSON.parse(await object.Body.transformToString());
console.log('got succeeded object body', body);

return JSON.parse(body[0].Input);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading