Use random string for unknown exchange type tests#204
Merged
Conversation
Previously, the tests passed `none` as the exchange type and asserted on the "invalid exchange type" error. That path only fires in `rabbit_exchange:check_type/1` when the type is a known atom whose module lookup fails — `none` happens to already be interned as an atom in the VM, so `binary_to_existing_atom/1` succeeds and the module lookup is what fails.
A random string exercises the other branch: `binary_to_existing_atom/1` returns `{error, not_found}` in `rabbit_registry:binary_to_type/1`, and the broker replies with "unknown exchange type '<name>'".
However, this breaks it for LavinMQ < 2.8.0 (not yet released) which uses another error message ("invalid exchange type") so temporarily broaden the regex to allow for both types of messages.
There was a problem hiding this comment.
Pull request overview
Updates the AMQP client test suite to exercise the broker path for truly unknown exchange types (rather than relying on "none" being an existing atom on some brokers/VMs), while keeping compatibility with older LavinMQ error wording.
Changes:
- Replace
"none"exchange type usage with a randomized, non-existent exchange type string. - Broaden error-message assertions to accept both “unknown exchange type” and “invalid exchange type” across RabbitMQ and LavinMQ versions.
viktorerlingsson
approved these changes
Apr 22, 2026
ThomasSarlin
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the tests passed "none" as the exchange type and asserted on the "invalid exchange type" error. In RabbitMQ, that path only fires in
rabbit_exchange:check_type/1when the type is a known atom whose module lookup fails — "none" happens to already be interned as an atom in the VM, sobinary_to_existing_atom/1succeeds and the module lookup is what fails.A random string, on the other hand, exercises the other branch:
binary_to_existing_atom/1returns{error, not_found}inrabbit_registry:binary_to_type/1, and the broker replies with "unknown exchange type ''".However, the change to random strings breaks compatibility with LavinMQ < 2.8.0 (2.8.0 will include cloudamqp/lavinmq#1811), temporarily broaden the regex to allow for both types of messages.