BigPizzaV3/CodexPlusPlus · error
测试模型不能为空
Error message
测试模型不能为空
What it means
test_relay_profile sends a live request whose payload names a model; the test model parameter is trimmed and must be non-empty, otherwise the library bails before constructing relay_profile_test_payload. A request body without a model would be rejected by the relay anyway, so this is caught locally.
Solutions
- Pass a non-empty model name (e.g. "gpt-4o" or a model from the profile's model_list) to test_relay_profile
- Pre-fill the test model from the profile's first configured model in the UI
- Validate the model field in the UI before triggering the test
Example fix
// before test_relay_profile(&profile, " ")?; // after test_relay_profile(&profile, "deepseek-v4-pro")?;
Defensive patterns
Strategy: validation
Validate before calling
if model.trim().is_empty() {
return Err(anyhow::anyhow!("测试模型不能为空"));
} Try / catch
match test_relay_profile(&profile, &model) {
Err(e) if e.to_string().contains("测试模型不能为空") => preselect_first_model(&profile)?,
other => other?,
} Prevention
- Default the test model to the first entry of the profile's model_list
- Disable the test button until a model is chosen
- Validate form fields before calling the test API
When it happens
Trigger: Calling test_relay_profile(profile, model) with model == "" or whitespace only.
Common situations: The manager UI's 'test' button clicked before the user selected a model; a profile's default model field is blank because model_list was never populated.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/529a673743ead1e4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/relay_config.rs:682
let base_url = relay_profile_base_url(profile);
let base_url = base_url.trim().trim_end_matches('/');
if base_url.is_empty() {
anyhow::bail!("Base URL 不能为空");
}
let api_key = relay_profile_api_key(profile);
let api_key = api_key.trim();
if api_key.is_empty() && !profile.uses_no_auth() {
anyhow::bail!("API Key 不能为空");
}
let client = crate::http_client::proxied_client("CodexPlusPlus/RelayTest")?;
let endpoint = match profile.protocol {
RelayProtocol::Responses => format!("{base_url}/responses"),
RelayProtocol::ChatCompletions => format!("{base_url}/chat/completions"),
};
let test_model = model.trim();
if test_model.is_empty() {
anyhow::bail!("测试模型不能为空");
}
let payload = relay_profile_test_payload(profile.protocol, test_model);
let mut request = client
.post(&endpoint)
.header(reqwest::header::CONTENT_TYPE, "application/json")
.json(&payload);
if !profile.uses_no_auth() {
request = request.bearer_auth(api_key);
}
let response = request.send().await?;
let http_status = response.status().as_u16();
// 如果 404 且 base_url 末尾没有 /v1,尝试自动补 /v1 后再发一次。
// 许多上游(中转站、自建代理)暴露的路径以 /v1/ 开头,
// 用户容易遗漏这个前缀,导致 /responses 或 /chat/completions 404。
if http_status == 404 && !base_url.ends_with("/v1") {
let v1_url = format!("{base_url}/v1");View on GitHub (pinned to b1ed92e5e4)