Skip to content

Use random string for unknown exchange type tests#204

Merged
walro merged 1 commit intomainfrom
unknown-exchange-tests
Apr 22, 2026
Merged

Use random string for unknown exchange type tests#204
walro merged 1 commit intomainfrom
unknown-exchange-tests

Conversation

@walro
Copy link
Copy Markdown
Contributor

@walro walro commented Apr 22, 2026

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/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, on the other hand, 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 ''".

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.

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/test.ts
@walro walro marked this pull request as ready for review April 22, 2026 10:43
@walro walro merged commit b9bf100 into main Apr 22, 2026
19 of 20 checks passed
@walro walro deleted the unknown-exchange-tests branch April 22, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants