BigPizzaV3/CodexPlusPlus · error · anyhow::Error
模型路由目标不能是聚合供应商:
Error message
模型路由目标不能是聚合供应商:{} What it means
select_model_route validates that a route's target relay is a concrete upstream. If the resolved target profile has relay_mode == Aggregate, routing to it is rejected, since aggregates are local fan-out constructs and cannot themselves serve as an upstream for a single routed request.
Solutions
- Change the route's target_relay_id to one of the aggregate's concrete member relay ids
- Use the CodexPlusPlus UI's route editor and pick a non-aggregate (direct) provider as target
- If you need fan-out behavior, rely on the aggregate provider's own member selection instead of an explicit route
Example fix
# before target_relay_id = "agg" # aggregate # after target_relay_id = "relay-b" # member of agg
Defensive patterns
Strategy: validation
Validate before calling
let target = settings.relay_profiles.iter().find(|p| p.id == route.target_relay_id);
if let Some(t) = target {
if t.relay_mode == RelayMode::Aggregate {
return Err(anyhow!("route target must be a direct provider, not aggregate {}", t.name));
}
} Try / catch
match select_model_route(&settings, model) {
Ok(Some(sel)) => forward(sel),
Err(e) if e.to_string().contains("不能是聚合供应商") => surface_route_config_error(e),
Err(e) => return Err(e),
} Prevention
- Filter aggregate providers out of the route-target picker in the UI
- Validate routes on settings save
- Name aggregates clearly (prefix 'agg-') to avoid accidental selection
When it happens
Trigger: A model route's target_relay_id resolves to a relay profile whose relay_mode is Aggregate, so the validation `target.relay_mode == RelayMode::Aggregate` triggers the bail with the target's name.
Common situations: User pointed a model route at an aggregate provider by mistake, intending one of its members; UI allowed selecting an aggregate in the route target dropdown; ids were shuffled during settings editing.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/37f27090abf5a28f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/protocol_proxy.rs:801
let Some(route) = source
.model_routes
.iter()
.find(|route| route.model.trim() == model)
else {
return Ok(None);
};
let target_relay_id = route.target_relay_id.trim();
if target_relay_id == source.id {
anyhow::bail!("模型路由不能指向当前供应商自身:{model}");
}
let target = settings
.relay_profiles
.iter()
.find(|profile| profile.id == target_relay_id)
.cloned()
.with_context(|| format!("模型路由目标供应商不存在:{target_relay_id}"))?;
if target.relay_mode == crate::settings::RelayMode::Aggregate {
anyhow::bail!("模型路由目标不能是聚合供应商:{}", target.name);
}
if target.protocol != RelayProtocol::Responses {
anyhow::bail!("模型路由目标必须使用 Responses API:{}", target.name);
}
let upstream_model = if route.target_model.trim().is_empty() {
model.to_string()
} else {
route.target_model.trim().to_string()
};
Ok(Some(ModelRouteSelection {
relay: target,
source_relay_id: source.id,
source_model: model.to_string(),
upstream_model,
}))
}
View on GitHub (pinned to b1ed92e5e4)