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

Throw a meaningful exception when a binding name is too long #453

Open
mauroservienti opened this issue Nov 21, 2017 · 11 comments
Open

Throw a meaningful exception when a binding name is too long #453

mauroservienti opened this issue Nov 21, 2017 · 11 comments
Labels

Comments

@mauroservienti
Copy link
Member

mauroservienti commented Nov 21, 2017

A customer came to me with the following error at endpoint startup:

RabbitMQ.Client.Exceptions.WireFormattingException: Short string too long; UTF-8 encoded length=260, max=255
   at RabbitMQ.Client.Impl.WireFormatting.WriteShortstr(NetworkBinaryWriter writer, String val)
   at RabbitMQ.Client.Framing.Impl.QueueBind.WriteArgumentsTo(MethodArgumentWriter writer)
   at RabbitMQ.Client.Impl.Command.TransmitAsSingleFrame(Int32 channelNumber, Connection connection)

The customer was using DirectRoutingTopology and one binding was too long. The thing is that all their events inherit from a base class; thus the binding name was namespace-base-class.namespace-derived-class. They added a new event where the entire string was 5 chars longer than allowed. Being the above error useless, it took us, the customer and myself, nearly two hours to figure out what was going on and identify the source of the error.

Given that we are creating those bindings, we should wrap the broker exception in a custom one adding some details, such as the entity name that is causing the failure.

@adamralph adamralph changed the title When binding name is too long the exception raised by the RabbitMQ client is meaningless Throw a meaningful exception when a binding name is too long Nov 21, 2017
@adamralph
Copy link
Member

👍 thanks for raising @mauroservienti. I've renamed to reflect this as a new "feature".

@mauroservienti
Copy link
Member Author

Thank you

@bording bording added this to the 5.1.0 milestone Jan 10, 2019
@andreasohlund
Copy link
Member

The description mentions DirectRoutingTopology which is pretty much no longer used but I assume the same thing could happen with the conventional one?

@bording
Copy link
Member

bording commented Mar 21, 2019

The description mentions DirectRoutingTopology which is pretty much no longer used

There's nothing that we've done that actually prevents people from using it, so I'm not sure that's actually true.

I assume the same thing could happen with the conventional one?

Yeah, there are some length limitations in there as well, so this could apply more generally. I've started looking at what could be done here.

@bording
Copy link
Member

bording commented Mar 21, 2019

Looking at this a bit more, I do think there is more we can do here, but if we change the exception type we expose to users by wrapping the client exceptions in something like Exception instead, that is technically a breaking behavior change.

Would be be okay with going from throwing RabbitMQ.Client.Exceptions.WireFormattingException or RabbitMQ.Client.Exceptions.OperationInterruptedException to just Exception in a minor release?

@andreasohlund
Copy link
Member

andreasohlund commented Mar 21, 2019 via email

@bording
Copy link
Member

bording commented Mar 21, 2019

I do generally think that changing the exception type the way we'd need to here is a break. Someone could have code that is catching the existing exceptions and doing something in the catch blocks.

If we changed to Exception, then those catch blocks would no longer catch the exceptions, and we'd have broken them.

That's why I'm thinking we'd really need to wait for a new major to do this.

@andreasohlund
Copy link
Member

andreasohlund commented Mar 21, 2019 via email

@bording
Copy link
Member

bording commented Mar 21, 2019

FYI to make this work the way we'd want to, we'd also need to stop swallowing exceptions in https://github.com/Particular/NServiceBus.RabbitMQ/blob/develop/src/NServiceBus.Transport.RabbitMQ/Routing/ConventionalRoutingTopology.cs#L138-L140
and https://github.com/Particular/NServiceBus.RabbitMQ/blob/develop/src/NServiceBus.Transport.RabbitMQ/Routing/DirectRoutingTopology.cs#L72-L76

which I think would probably be a good thing anyway, but this really gets outside the realm of what should be done in a minor.

I'll remove this from the 5.1.0 milestone, and we can revisit when we release a new major.

@bording bording removed this from the 5.1.0 milestone Mar 21, 2019
@ramonsmits ramonsmits added this to the 6.0.0 milestone Jun 30, 2020
@tmasternak
Copy link
Member

tmasternak commented Jul 10, 2020

This will be solved when this PR is merged into the Rabbit Client library.

@tmasternak tmasternak removed this from the 6.0.0 milestone Jul 10, 2020
@bording
Copy link
Member

bording commented Jul 10, 2020

The client PR gets us most of the way there since it means the exception thrown from the client will contain the offending value, so it should be more obvious which string it is that is causing the problem.

We could leave this open to further improve things, trying to surface a "queue name too long" or "binding too long" exception that points user even more in the right direction, but I'm not sure if that's worth doing or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants