localstack icon indicating copy to clipboard operation
localstack copied to clipboard

bug: EventBridge EventPattern does not match detail-type with equals-ignore-case

Open fercarcedo opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

When creating a rule that matches events by their detail-type property using the equals-ignore-case filter, the rule is created successfully, but when putting events the rule does not get triggered.

This seems to be similar to this issue (https://github.com/localstack/localstack/issues/8512), but for the detail-type property instead of the detail one.

In the example below, the event does not get logged to CloudWatch and there are no created log streams in the log group. However, removing the equals-ignore-case filter (so that the comparison is for full equality), then the event gets logged.

Expected Behavior

A log stream should be created in the log group with the contents of the sent event.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

version: "3.8"

services:
    localstack:
        container_name: "${LOCALSTACK_DOCKER_NAME-localstack-main}"
        image: localstack/localstack:3.1
        ports:
             - "127.0.0.1:4566:4566"            # LocalStack Gateway
             - "127.0.0.1:4510-4559:4510-4559"  # external services port range
        environment:
            - DEBUG=1
            - DOCKER_HOST=unix:///var/run/docker.sock
        volumes:
             - "./init-aws.sh:/etc/localstack/init/ready.d/init-aws.sh"  # ready hook
             - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
             - "/var/run/docker.sock:/var/run/docker.sock"

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

awslocal logs create-log-group --log-group-name /aws/events/test-group
awslocal events create-event-bus --name "test-event-bus"
awslocal events put-rule \                             
    --name test-rule \
    --event-pattern "{\"detail-type\":[{\"equals-ignore-case\":\"test-detail-type\"}]}" \
    --event-bus-name "test-event-bus"
awslocal events put-targets \                          
    --rule test-rule \
    --targets file://targets.json \
    --event-bus-name test-event-bus

 awslocal events put-events --entries file://events.json

 awslocal logs describe-log-streams \
    --log-group-name /aws/events/test-group

 // The above command shows no log streams, but shows one created log stream when removing the equals-ignore-case matcher:
//   --event-pattern "{\"detail-type\":[\"test-detail-type\"]}" \
events.json file
[
    {
        "Source": "com.mycompany.myapp",
        "EventBusName": "test-event-bus",
        "Detail": "{\"key1\":\"value1\"}",
        "DetailType": "test-detail-type"
    }
]
targets.json file
[
    {
          "Id": "1", 
          "Arn": "arn:aws:logs:us-east-1:000000000000:log-group:/aws/events/test-group"
    }
]

Environment

- OS: Ubuntu 22.04
- LocalStack: 3.1 (also tested on latest)

Anything else?

No response

fercarcedo avatar Feb 13 '24 17:02 fercarcedo

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

localstack-bot avatar Feb 13 '24 17:02 localstack-bot

@fercarcedo thanks for bringing this to our attention, we released last week the brand new EventBridge v2 with LocalStack 3.5, amongst many other improvements and parity fixes it also shipped the new RuleMatching engine, which fixes the above-described issue.

You can use the new EventBridge v2 by setting the environment variable PROVIDER_OVERRIDE_EVENTS=v2 - please let us know if you encounter any additional issues.

maxhoheiser avatar Jun 18 '24 12:06 maxhoheiser

Thank you!

fercarcedo avatar Jun 18 '24 12:06 fercarcedo