BrighterCommand / BrighterCommand/Brighter

Action On A Missing Request Type When Mapping from Cloud Events Event Type

Open
#4,223 0 comments 0 reactions 0 assignees View on GitHub
.NET 0 - Backlog Breaking Change feature request V11
Dominant language
C#
Stars
2.5k
Forks
296
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Requirement
### Discussed in https://github.com/BrighterCommand/Brighter/discussions/4213

Originally posted by **dssldavidmorgan** July 2, 2026
I set up my `RmqSubscription` objects like below, so that a cloud events type string maps to a `Type` which is a request type. The `getRequestType` gets the associated type from the message's cloud events type header and returns null if it's not found.

What I want to know is how I should handle the case where there may be message types received that the service isn't interested in consuming.

Currently, the `getRequestType` method signature doesn't accept a null value returned, and it logs a noisy warning whenever a message type is received that doesn't have a handler.

```csharp
var messageTypes = subscriptions.ToDictionary(x => x.Type, x => x.RequestType);

var rmqSubscriptions = subscriptions.ConvertAll(x => new RmqSubscription(
...
getRequestType: message => messageTypes.TryGetValue(message.Header.Type.Value, out var messageType) ? messageType : null!,
...));
```

In both the Proactor and the Reactor the getRequestType function is used like this:

```csharp
var requestType = _mapRequestType(message);
if (requestType == null)
throw new MessageMappingException($"Failed to find request type for message {message.Id} ",
new ArgumentNullException(nameof(requestType), "The request type cannot be null."));
```

It expects that requestType might be null, although the signature doesn't suggest that it should return null, and it always throws an exception, which gets logged as a warning. Useful if you've made a configuration error, but noisy if you just want to ignore certain message types.

## Proposal

We may need to provide an Option Type return value that lets the implementor signal via a bool if they wish to throw or drop silently. As this would change the signature of the mapping function, we would need to change this in V11. As part of that change we would need to consider the easiest migration path for existing implementations

Note that the original discussion included an IgnoreHandler which could silently consume the message, which provides a workaround. If that workaround were tagged with a DLQ or Invalid Message queue and threw the relevant exception, this would be another alternative that would mean we were not silently losing messages, where a DLQ was configured. This might be a better built in alternative than the Option<> type

Contributor guide

Open the contributing guide

Research direction

Start by tracing the getRequestType mapping entry point through both the Proactor and Reactor paths, especially the null check that raises MessageMappingException. Review the linked discussion and compare the proposed Option type with the IgnoreHandler and DLQ alternatives; done requires a decided behavior, a migration path for existing implementations, and corresponding implementation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, rabbitmq
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.