Skip to content

Commit

Permalink
Merge pull request #388 from jgilbert01/issue-claimcheck-incorrect-en…
Browse files Browse the repository at this point in the history
…try-request

Fix request entry.
  • Loading branch information
petermyers authored Oct 29, 2024
2 parents 71d1c37 + df12071 commit 895ae2a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-lambda-stream",
"version": "1.0.26",
"version": "1.0.27",
"description": "Create stream processors with AWS Lambda functions.",
"keywords": [
"aws",
Expand Down
7 changes: 5 additions & 2 deletions src/utils/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ export const batchWithSize = ({
logMetrics([x], [size], opt);
if (claimCheckBucketName) {
// setup claim check
x[putClaimcheckRequest] = toPutClaimcheckRequest(x[opt.requestEntryField], claimCheckBucketName);
x[opt.requestEntryField] = toClaimcheckEvent(x[opt.requestEntryField], claimCheckBucketName);
x[putClaimcheckRequest] = toPutClaimcheckRequest(JSON.parse(x[opt.requestEntryField].Detail), claimCheckBucketName);
x[opt.requestEntryField].Detail = JSON.stringify(toClaimcheckEvent(
JSON.parse(x[opt.requestEntryField].Detail),
claimCheckBucketName,
));
size = Buffer.byteLength(JSON.stringify(x[opt.requestEntryField]));
} else {
const error = new Error(`Request size: ${size}, exceeded max: ${opt.maxRequestSize}`);
Expand Down
34 changes: 16 additions & 18 deletions test/unit/sinks/claimcheck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ describe('sinks/claimcheck.js', () => {
const spy = sinon.spy();
const uows = [
{
publishRequestEntry: { // size = 23
id: '1',
body: 'xxx',
publishRequestEntry: {
Detail: JSON.stringify({ // size = 23
id: '1',
body: 'xxx',
}),
},
},
{
publishRequestEntry: { // size = 33
id: '2',
body: 'xxxxxxxxxxxxx',
publishRequestEntry: {
Detail: JSON.stringify({ // size = 33
id: '2',
body: 'xxxxxxxxxxxxx',
}),
},
},
{
publishRequestEntry: { // size = 140
id: '3',
body: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
publishRequestEntry: {
Detail: JSON.stringify({ // size = 140
id: '3',
body: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}),
},
},
];
Expand All @@ -52,15 +58,7 @@ describe('sinks/claimcheck.js', () => {
expect(collected[1]).to.deep.equal([
{
publishRequestEntry: { // size = 39
id: '3',
type: undefined,
partitionKey: undefined,
timestamp: undefined,
tags: undefined,
s3: {
bucket: 'event-lake-s3',
key: 'us-west-2/claimchecks/2024/8/20/17/3',
},
Detail: '{"id":"3","s3":{"bucket":"event-lake-s3","key":"us-west-2/claimchecks/2024/8/20/17/3"}}',
},
putClaimcheckRequest: {
Bucket: 'event-lake-s3',
Expand Down

0 comments on commit 895ae2a

Please sign in to comment.