{"record":{"id":"e5884c49900ee1a9","repo":"BigPizzaV3/CodexPlusPlus","slug":"base-url-e5884c","errorCode":null,"errorMessage":"Base URL 格式无效","messagePattern":"Base URL 格式无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/routes.rs","lineNumber":785,"sourceCode":"        .map(str::trim)\n        .is_some_and(|value| value.eq_ignore_ascii_case(\"application/json\"))\n    {\n        serde_json::from_slice::<Value>(&bytes).ok()\n    } else {\n        None\n    };\n\n    Ok(json!({\n        \"status\": \"ok\",\n        \"http_status\": http_status,\n        \"ok\": ok,\n        \"body_text\": body_text,\n        \"body_json\": body_json,\n    }))\n}\n\nfn validate_llm_proxy_url(raw: &str) -> anyhow::Result<reqwest::Url> {\n    let url = reqwest::Url::parse(raw.trim()).map_err(|_| anyhow::anyhow!(\"Base URL 格式无效\"))?;\n    if url.scheme() != \"https\" {\n        anyhow::bail!(\"Base URL 必须使用 HTTPS\");\n    }\n    if !url.username().is_empty() || url.password().is_some() {\n        anyhow::bail!(\"Base URL 不得包含用户名或密码\");\n    }\n    let host = url\n        .host_str()\n        .ok_or_else(|| anyhow::anyhow!(\"Base URL 缺少主机名\"))?;\n    if is_blocked_llm_proxy_host(host) {\n        anyhow::bail!(\"Base URL 不得指向本机或私有网络\");\n    }\n    Ok(url)\n}\n\nfn is_blocked_llm_proxy_host(host: &str) -> bool {\n    let host = host\n        .trim()","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/routes.rs#L767-L803","documentation":"validate_llm_proxy_url parses a user-supplied LLM proxy Base URL with reqwest::Url::parse before the app uses it. If the string cannot be parsed as an absolute URL (relative path, missing scheme, illegal characters), the parse error is replaced with this Chinese-language message. This is an input-validation error from the llm_proxy_value handler.","triggerScenarios":"Entering a Base URL like \"api.example.com/v1\" (no scheme), \"http://\" with an empty host, a URL with spaces or unsupported characters, or an empty string into the proxy config.","commonSituations":"Typing a host without https:// in the relay profile form; pasting a URL with trailing whitespace or invisible characters; missing scheme after a config migration.","solutions":["Prepend the scheme: change \"api.example.com/v1\" to \"https://api.example.com/v1\".","Trim whitespace and remove illegal characters from the URL before saving.","Use a full absolute URL including host (e.g. https://host[:port]/path).","Validate the URL in the frontend input before submitting to the route."],"exampleFix":"// before\nlet base = \"api.deepseek.com/v1\";\n// after\nlet base = \"https://api.deepseek.com/v1\";","handlingStrategy":"validation","validationCode":"function isValidProxyBase(raw: string): boolean {\n  try {\n    const u = new URL(raw.trim());\n    return u.protocol === 'https:' && u.hostname.length > 0;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.setLlmProxy({ baseUrl });\n} catch (e) {\n  if (String(e).includes('Base URL 格式无效')) {\n    showFieldError('base_url', '请输入以 https:// 开头的完整 URL');\n  } else { throw e; }\n}","preventionTips":["Always include the https:// scheme in Base URL fields.","Trim user input before saving.","Validate URL format client-side before submitting.","Avoid pasting URLs through channels that add whitespace or Unicode quotes."],"tags":["url","validation","config"],"backgroundTag":"invalid-url-format","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"}