Skip to content

Error when throwing an exception in a behavior. #7761

@pborgmans

Description

@pborgmans

Describe the bug

Description

When encountering an error in a behavior we're getting this exception:

System.ArgumentException: The value "False" is not of type "System.String" and cannot be used in this generic collection. (Parameter 'value')
   at System.Collections.Generic.Dictionary`2.System.Collections.IDictionary.set_Item(Object key, Object value) 
   at NServiceBus.MainPipelineExecutor.Invoke(MessageContext messageContext, CancellationToken cancellationToken) in /_/src/NServiceBus.Core/Pipeline/MainPipelineExecutor.cs:line 67
   at NServiceBus.MainPipelineExecutor.Invoke(MessageContext messageContext, CancellationToken cancellationToken) in /_/src/NServiceBus.Core/Pipeline/MainPipelineExecutor.cs:line 82
   at NServiceBus.Transport.AzureServiceBus.MessagePump.ProcessMessage(ServiceBusReceivedMessage message, ProcessMessageEventArgs processMessageEventArgs, String nativeMessageId, Dictionary`2 headers, BinaryData body, CancellationToken messageProcessingCancellationToken) in /_/src/Transport/Receiving/MessagePump.cs:line 263

This refers to this line of code: (https://github.com/Particular/NServiceBus/blob/master/src/NServiceBus.Core/Pipeline/MainPipelineExecutor.cs#L12)
ex.Data["Pipeline canceled"] = transportReceiveContext.CancellationToken.IsCancellationRequested;
So if I understand correctly it's not allowed to put a bool value into the dictionary, it expects a string value.

Expected behavior

Get the original exception that is failing in the pipeline, this exception hides the original error.

Actual behavior

An exception is happening in the MainPipelineExecutor which causes the original exception to not be shown.

Versions

10.1.4

Please list the version of the relevant packages or applications in which the bug exists.

Steps to reproduce

Add a behavior which throws an exception

Relevant log output

Additional Information

Workarounds

No blocker, just lack of information of what the original error was.

Possible solutions

.ToString() on the bool value.

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions