Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.
Rust
fix: Do not advertise the model directory (#67)
Graham King487fa4c8f815
diff --git a/crates/switchyard-server/src/registry.rs b/crates/switchyard-server/src/registry.rsindex dd00956c1..20b829c05 100644--- a/crates/switchyard-server/src/registry.rs+++ b/crates/switchyard-server/src/registry.rs@@ -67,13 +67,6 @@ impl ProfileRegistry {Arc::clone(&profile),target.model.as_str(),)?;- if target.id.as_str() != target.model.as_str() {- registry.insert(- target.model.clone(),- profile,- format!("target {}", target.id.as_str()),- )?;- }}Ok(registry)diff --git a/crates/switchyard-server/tests/server.rs b/crates/switchyard-server/tests/server.rsindex fd73be698..90ee30b1b 100644--- a/crates/switchyard-server/tests/server.rs+++ b/crates/switchyard-server/tests/server.rs@@ -206,60 +206,6 @@ async fn translation_errors_do_not_emit_routing_metadata_headers() -> TestResultOk(())}-#[tokio::test]-async fn target_id_and_target_model_aliases_are_advertised_and_routable() -> TestResult {- let _stats_guard = stats_guard().await;- let Some(stub) = HttpStub::start(2)? else {- log_loopback_bind_skip();- return Ok(());- };- let app = build_switchyard_router(state_from_yaml(&format!(- r#"-targets:- direct:- model: upstream-direct- format: openai- base_url: {base_url}-profiles:- direct-profile:- type: passthrough- target: direct-"#,- base_url = stub.base_url- ))?);-- let models = app- .clone()- .oneshot(request("GET", "/v1/models", None)?)- .await?;- let model_ids = json_body(models).await?["model_pool"].clone();- assert_eq!(- model_ids,- json!(["direct-profile", "direct", "upstream-direct"])- );-- for public_model in ["direct", "upstream-direct"] {- let response = app- .clone()- .oneshot(request(- "POST",- "/v1/chat/completions",- Some(json!({- "model": public_model,- "messages": [{"role": "user", "content": "hi"}],- })),- )?)- .await?;- assert_eq!(response.status(), StatusCode::OK);- }-- let seen = stub.requests()?;- assert_eq!(seen.len(), 2);- assert_eq!(seen[0]["model"], "upstream-direct");- assert_eq!(seen[1]["model"], "upstream-direct");- Ok(())-}-#[tokio::test]async fn target_with_same_id_and_model_is_registered_once() -> TestResult {let _stats_guard = stats_guard().await;@@ -406,28 +352,6 @@ profiles:Ok(())}-#[tokio::test]-async fn duplicate_public_model_ids_are_rejected() -> TestResult {- let err = state_from_yaml(- r#"-targets:- direct:- model: same- format: openai- base_url: http://127.0.0.1:9/v1-profiles:- same:- type: noop-"#,- )- .err()- .ok_or("expected duplicate public model id failure")?;-- assert!(err.to_string().contains("same"));- assert!(err.to_string().contains("already registered"));- Ok(())-}-#[tokio::test]async fn stats_endpoints_use_components_v2_global_accumulator() -> TestResult {let _stats_guard = stats_guard().await;