Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

EventBridge API returns 'InternalFailure' error when 'resources' contain a 'null' value #39

@julealgon

Description

@julealgon

Description

When calling IAmazonEventBridge.PutEventsAsync with an event entry having the Resources property initialized to a collection containing a null string, the service returns a generic InternalFailure error containing the message "Internal Service Failure".

The documentation for InternalFailureException indicates it is thrown due to unknown circumstances, however this appears to be a simple input validation gap on the EventBridge backend: if null resource values are not accepted, then they should be validated.

Reproduction Steps

  1. Call IAmazonEventBridge.PutEventsAsync with an event containing a null entry in the Resources collection (see example below):
    public class Something
    {
        private readonly IAmazonEventBridge amazonEventBridge;

        public Something(IAmazonEventBridge amazonEventBridge)
        {
            this.amazonEventBridge = amazonEventBridge;
        }

        public async Task PublishEventAsync()
        {
            var request = new PutEventsRequest
            {
                Entries =
                {
                    new PutEventsRequestEntry
                    {
                        Detail = "{}",
                        DetailType = "EventType",
                        Source = "EventSource",

                        // Notice this adds a 'null' element to the collection, which is different than setting the collection to 'null'
                        Resources = { null },
                    },
                },
            };

            var response = await this.amazonEventBridge.PutEventsAsync(request);
        }
    }
  1. Observe the returned payload in response:
{
    "Entries": [{
            "ErrorCode": "InternalFailure",
            "ErrorMessage": "Internal Service Failure",
            "EventId": null
        }
    ],
    "FailedEntryCount": 1,
    "ResponseMetadata": {
        "RequestId": "a99c1d6a-d800-4bda-b1b4-f54f3996ef2c",
        "Metadata": {}
    },
    "ContentLength": 108,
    "HttpStatusCode": 200
}

Environment

  • SDK Version:
  • Package Version: AWSSDK.EventBridge v3.5.4.26
  • OS Info: Windows 10
  • Build Environment Visual Studio
  • Targeted .NET Platform: NetCore 3.1

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

The problem here appears to be related to input validation on the EventBridge API. Instead of returning an InternalError, which basically means "we have no idea what happened here", it should be validating that none of the entries in Resources is null and returning a more appropriate error and message when that's the case.

The current error might end up causing frustration on developers who for some reason have this value coming from an external place and the resource value there being null.

I stumbled upon this while testing my logic by passing the InvokedFunctionArn value from my lambda to the resources collection. Unfortunatelly, InvokedFunctionArn is always null while testing with the Mock Lambda Tool, which resulted in the resource value being null in the event.


This is a 🐛 bug-report

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingeventbridgeresponse-requestedThis issue requires a response to continue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions