Skip to content

fix(ingestion): replace SDK integration with Lambda for S3 listing#1886

Draft
iankhou wants to merge 2 commits into
mainfrom
fix/lambda-list-objects-reprocessing
Draft

fix(ingestion): replace SDK integration with Lambda for S3 listing#1886
iankhou wants to merge 2 commits into
mainfrom
fix/lambda-list-objects-reprocessing

Conversation

@iankhou
Copy link
Copy Markdown
Contributor

@iankhou iankhou commented May 27, 2026

Summary

  • Replaces the Step Functions CallAwsService SDK integration for ListObjectsV2 with a dedicated Lambda function
  • The Lambda returns only the Key field for each S3 object, eliminating the 256KB payload limit issue entirely
  • Removes the MaxKeys retry chain (Try1000→Try900→...) that was needed to work around States.DataLimitExceeded
  • Simplifies the state machine graph significantly

Problem

The SDK integration returns the full S3 ListObjectsV2 response including per-object metadata (ETag, LastModified, Size, StorageClass) for up to 1000 objects. This response can approach or exceed the 256KB Step Functions payload limit.

There's an uncatchable edge case where the response is just under 256KB (so the state reports success), but Step Functions aborts the execution at the state transition boundary when internal metadata pushes the total over the limit. This ExecutionFailed event is not tied to a specific state, making addCatch(States.DataLimitExceeded) ineffective.

Solution

A Lambda function calls ListObjectsV2 and returns only what the workflow needs:

  • Contents[].Key — the object keys
  • NextContinuationToken — for pagination (only when present)

This reduces the payload from ~200-300KB to ~50-100KB for 1000 objects, well within the limit. The Lambda controls its own output size, making the payload limit concern irrelevant.

Test plan

  • Run npx projen build to regenerate the construct class and bundle (projen auto-discovers *.lambda.ts files)
  • Verify snapshot tests pass after regeneration
  • Deploy and observe the daily reprocessing run succeeds with MaxKeys=1000
  • Monitor Lambda invocation metrics and errors

Related

iankhou added 2 commits May 26, 2026 16:52
Replace the Step Functions CallAwsService SDK integration for
ListObjectsV2 with a dedicated Lambda function that returns only the
Key field for each object. This eliminates the 256KB Step Functions
payload limit issue entirely — the Lambda controls what it returns,
stripping per-object metadata (ETag, LastModified, Size, StorageClass)
that bloats the SDK integration response.

This removes the need for the MaxKeys retry chain (Try1000→Try900→...)
and simplifies the state machine significantly.
@iankhou
Copy link
Copy Markdown
Contributor Author

iankhou commented May 29, 2026

Testing this in development to verify that the lambda works as expected.

@iankhou iankhou self-assigned this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant