Skip to content

Fix Typo in ResponseCode::PrecoditionFailed #306

@Mpinyaz

Description

@Mpinyaz

Describe the bug

Summary

There is a misspelled enum variant in ResponseCode within the rabbitmq-stream-client Rust crate.

The variant is currently named:

ResponseCode::PrecoditionFailed

This is a typo and should be:

ResponseCode::PreconditionFailed

Although the numeric mapping is correct (RESPONSE_CODE_PRECONDITION_FAILED), the enum variant name itself is incorrect


Impact

  • Developers must use an incorrect spelling (PrecoditionFailed) when matching response codes.
  • Causes confusion when debugging and reading code.
  • Mismatched variant name breaks common naming conventions and is inconsistent with AMQP/RabbitMQ terminology.

Proposed Fix

Rename the enum variant and update all match arms accordingly:

- ResponseCode::PrecoditionFailed
+ ResponseCode::PreconditionFailed

And update both the TryFrom<u16> and From<&ResponseCode> implementations:

- RESPONSE_CODE_PRECONDITION_FAILED => Ok(ResponseCode::PrecoditionFailed),
+ RESPONSE_CODE_PRECONDITION_FAILED => Ok(ResponseCode::PreconditionFailed),
- ResponseCode::PrecoditionFailed => RESPONSE_CODE_PRECONDITION_FAILED,
+ ResponseCode::PreconditionFailed => RESPONSE_CODE_PRECONDITION_FAILED,

Reproduction steps

  1. Create or interact with a RabbitMQ Stream and cause a RESPONSE_CODE_PRECONDITION_FAILED response.
  2. Observe how the client maps the numeric code using TryFrom<u16> for ResponseCode.
  3. Inspect the resulting enum variant returned by the library.
  4. You will see the misspelled variant ResponseCode::PrecoditionFailed instead of the expected ResponseCode::PreconditionFailed.
  5. Attempt to match on this variant in your own code.
  6. Notice that you must use the misspelled identifier, causing confusing or inconsistent code.

Expected behavior

  • The library should expose the correctly spelled enum variant ResponseCode::PreconditionFailed.
  • All conversions (TryFrom<u16> and From<&ResponseCode>) should map to and from this correct variant.
  • Developers should be able to match errors using the correct and conventional spelling.
  • Log outputs and error messages should report PreconditionFailed, not PrecoditionFailed.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions