{"record":{"id":"e4dc0a8db13ccbc1","repo":"BigPizzaV3/CodexPlusPlus","slug":"model","errorCode":null,"errorMessage":"模型路由不能指向当前供应商自身：{model}","messagePattern":"模型路由不能指向当前供应商自身：(.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/protocol_proxy.rs","lineNumber":792,"sourceCode":"fn select_model_route(\n    settings: &crate::settings::BackendSettings,\n    model: &str,\n) -> anyhow::Result<Option<ModelRouteSelection>> {\n    if model.is_empty() || settings.active_aggregate_relay_profile().is_some() {\n        return Ok(None);\n    }\n\n    let source = settings.active_relay_profile();\n    let Some(route) = source\n        .model_routes\n        .iter()\n        .find(|route| route.model.trim() == model)\n    else {\n        return Ok(None);\n    };\n    let target_relay_id = route.target_relay_id.trim();\n    if target_relay_id == source.id {\n        anyhow::bail!(\"模型路由不能指向当前供应商自身：{model}\");\n    }\n    let target = settings\n        .relay_profiles\n        .iter()\n        .find(|profile| profile.id == target_relay_id)\n        .cloned()\n        .with_context(|| format!(\"模型路由目标供应商不存在：{target_relay_id}\"))?;\n    if target.relay_mode == crate::settings::RelayMode::Aggregate {\n        anyhow::bail!(\"模型路由目标不能是聚合供应商：{}\", target.name);\n    }\n    if target.protocol != RelayProtocol::Responses {\n        anyhow::bail!(\"模型路由目标必须使用 Responses API：{}\", target.name);\n    }\n\n    let upstream_model = if route.target_model.trim().is_empty() {\n        model.to_string()\n    } else {\n        route.target_model.trim().to_string()","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/protocol_proxy.rs#L774-L810","documentation":"select_model_route resolves a model-based route for an incoming request. When the matched route's target_relay_id equals the source relay's own id, the request would loop back to the originating provider, so it is rejected with this error to prevent self-routing cycles.","triggerScenarios":"A model route table entry maps model {model} to target_relay_id that is identical to the id of the relay profile handling the request (source.id), typically due to a copy-paste mistake in settings.","commonSituations":"User created a route entry on an aggregate/member provider pointing to itself; duplicated relay ids in settings after cloning a profile; migration produced a route whose target defaulted to the source.","solutions":["Edit the model route in settings so target_relay_id points at a different relay profile","If the profile was cloned, ensure each profile has a unique id and fix stale duplicated ids","Remove the self-referencing route entry if it is unnecessary"],"exampleFix":"# before\n[[model_routes]]\nmodel = \"gpt-5\"\ntarget_relay_id = \"relay-a\"   # same as source relay-a\n# after\n[[model_routes]]\nmodel = \"gpt-5\"\ntarget_relay_id = \"relay-b\"","handlingStrategy":"validation","validationCode":"fn route_is_self_source(route: &ModelRoute, source_id: &str) -> bool {\n    route.target_relay_id.trim() == source_id\n}\n// call before saving settings; reject self-referencing routes","typeGuard":null,"tryCatchPattern":"match select_model_route(&settings, model) {\n    Ok(Some(sel)) => forward(sel),\n    Ok(None) => default_forward(),\n    Err(e) if e.to_string().contains(\"不能指向当前供应商自身\") => reject_config_and_prompt_user(e),\n    Err(e) => return Err(e),\n}","preventionTips":["Enforce target != source in the settings UI when creating routes","Use unique ids when cloning relay profiles","Review model_routes entries after importing or migrating settings"],"tags":["configuration","routing","proxy"],"backgroundTag":"invalid-config-value","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}