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

aws-lambda: FilterRule.null() returns empty array #31458

Open
1 task
ujjwol05 opened this issue Sep 16, 2024 · 1 comment
Open
1 task

aws-lambda: FilterRule.null() returns empty array #31458

ujjwol05 opened this issue Sep 16, 2024 · 1 comment
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@ujjwol05
Copy link

ujjwol05 commented Sep 16, 2024

Describe the bug

According to the documentation here, the FilterPattern should be [null]. However, the function FilterRule.null() currently returns an empty array [] instead.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The filter pattern for null should be
{ "eventName": [ "INSERT" ], "dynamodb": { "NewImage": { "test": { "S": [ null ] } } } }

Current Behavior

The filter pattern currently being returned is
{ "eventName": [ "INSERT" ], "dynamodb": { "NewImage": { "test": { "S": [] } } } }

Reproduction Steps

Construct an EventSourceMapping

new lambda.EventSourceMapping(
            this,
            `${stackPrefix}-lambda-event-source-mapping`,
            {
                startingPosition: StartingPosition.TRIM_HORIZON,
                target:XXXX,
                eventSourceArn: XXXX,
                reportBatchItemFailures: true,
                filters: [
                    lambda.FilterCriteria.filter({
                        eventName: lambda.FilterRule.isEqual('INSERT'),
                        dynamodb: {
                            NewImage: {
                                test: { S: lambda.FilterRule.exists() },
                            },
                        },
                    }),
                ],
            }
        );

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.155.0

Framework Version

No response

Node.js Version

v20.11.0

OS

Sonoma

Language

TypeScript

Language Version

No response

Other information

No response

@ujjwol05 ujjwol05 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 16, 2024
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Sep 16, 2024
@pahud pahud self-assigned this Sep 16, 2024
@pahud
Copy link
Contributor

pahud commented Sep 16, 2024

Yes

    new lambda.EventSourceMapping(
      this,
      'demo',
      {
          startingPosition: lambda.StartingPosition.TRIM_HORIZON,
          target: func,
          eventSourceArn: 'mock',
          reportBatchItemFailures: true,
          filters: [
              lambda.FilterCriteria.filter({
                  eventName: lambda.FilterRule.isEqual('INSERT'),
                  dynamodb: {
                      NewImage: {
                          test: { S: lambda.FilterRule.null() },
                      },
                  },
              }),
          ],
      }
  );

would synth to

 demo9A46DC86:
    Type: AWS::Lambda::EventSourceMapping
    Properties:
      EventSourceArn: mock
      FilterCriteria:
        Filters:
          - Pattern: '{"eventName":["INSERT"],"dynamodb":{"NewImage":{"test":{"S":[]}}}}'
      FunctionName:
        Ref: MyFunction3BAA72D1
      FunctionResponseTypes:
        - ReportBatchItemFailures
      StartingPosition: TRIM_HORIZON

which appears to be incorrect per doc.

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Sep 16, 2024
@pahud pahud removed their assignment Sep 16, 2024
@sumupitchayan sumupitchayan self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

3 participants