Skip to content

fix(steer): enforce fail-fast assertion for empty service iterators#866

Open
Alpy16 wants to merge 2 commits into
tower-rs:masterfrom
Alpy16:fix-steer-empty-services
Open

fix(steer): enforce fail-fast assertion for empty service iterators#866
Alpy16 wants to merge 2 commits into
tower-rs:masterfrom
Alpy16:fix-steer-empty-services

Conversation

@Alpy16
Copy link
Copy Markdown

@Alpy16 Alpy16 commented May 21, 2026

Closes #859

Description
Initializing Steer with an empty collection of services leaves the routing middleware in an unresolvable invariant state. While poll_ready will trivially return Poll::Ready(Ok(())), any subsequent invocation of call will immediately panic because there are no underlying target services to route the request to.

This patch adds an explicit assert!(!services.is_empty(), ...) check to the Steer::new constructor, shifting an operational runtime risk into a fast, upfront failure.

Type of Change
Bug fix (non-breaking change enforcing defensive API boundaries)

Verification
Added a #[should_panic] integration test in tower/tests/steer/main.rs with explicit type hinting to satisfy the compiler's inference engine.

Verified workspace tests pass via cargo test --test steer --all-features.

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.

Steer built with zero services returns poll_ready = Ready(Ok(())) but call panics

1 participant