Azure / Azure/azure-sdk-for-rust
eventhubs: close() reports an illegal local state after a failed CBS authorization
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 109
Description
## Summary
A client that fails CBS authorization cannot close cleanly. `close()` returns `Transport Implementation Error: Illegal local state`.
## Motivation
A live probe found this. The probe opened a `ProducerClient` with a corrupted shared access key. It called a management operation, and the CBS authorization of the `$management` path failed. It then called `close()`, which reported the error above.
The behavior appears on `main` and on the branch for #4806, so the management-client cache change does not cause it and does not fix it.
A caller that handles an authorization failure and then shuts down gets a second error that says nothing about the first. The error text points at the AMQP transport rather than at the credential, so it gives no useful signal. A caller cannot tell a real teardown fault apart from this one.
The mechanism is not diagnosed. The likely area is the connection or session state after a link fails to attach. The teardown path expects a state that the failed attach never reached. This needs a read of the close path in `sdk/eventhubs/azure_messaging_eventhubs/src/common/recoverable/connection.rs` and of the detach handling in `azure_core_amqp`.
## Proposal
Make `close()` succeed after a failed authorization, or return an error that names the real cause.
Add a test that opens a client with a credential the broker rejects, drives one operation to failure, and then asserts that `close()` returns `Ok`. The failure needs no valid credential, so the test can use a deliberately invalid key.
Related to #4728 and #4806, which cover the management path, and to #4811, which covers the CBS client cache. All concern the same subsystem.
Contributor guide
Research direction
Start by reading the close path in sdk/eventhubs/azure_messaging_eventhubs/src/common/recoverable/connection.rs and the detach handling in azure_core_amqp, focusing on state after a failed CBS authorization or link attach. Add a test using a deliberately invalid key that drives an operation to authorization failure and verifies that close() returns Ok.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100