{"record":{"id":"04b414888a04c2d6","repo":"BigPizzaV3/CodexPlusPlus","slug":"base-url-04b414","errorCode":null,"errorMessage":"上游 Base URL 不能为空","messagePattern":"上游 Base URL 不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/protocol_proxy.rs","lineNumber":1219,"sourceCode":"    relay: &crate::settings::RelayProfile,\n    is_stream: bool,\n    upstream_body: &Value,\n) -> reqwest::RequestBuilder {\n    let mut builder = client\n        .post(endpoint)\n        .header(reqwest::header::CONTENT_TYPE, \"application/json\");\n    builder = with_relay_auth(builder, relay);\n    if is_stream {\n        builder = builder\n            .header(reqwest::header::ACCEPT, \"text/event-stream\")\n            .header(reqwest::header::CACHE_CONTROL, \"no-cache\");\n    }\n    builder.json(upstream_body)\n}\n\nfn validate_upstream(relay: &crate::settings::RelayProfile) -> anyhow::Result<()> {\n    if relay.base_url.trim().is_empty() {\n        anyhow::bail!(\"上游 Base URL 不能为空\");\n    }\n    if relay.api_key.trim().is_empty() && !relay.uses_no_auth() {\n        anyhow::bail!(\"上游 Key 不能为空\");\n    }\n    Ok(())\n}\n\nfn with_relay_auth(\n    request: reqwest::RequestBuilder,\n    relay: &crate::settings::RelayProfile,\n) -> reqwest::RequestBuilder {\n    if relay.uses_no_auth() {\n        request\n    } else {\n        request.bearer_auth(relay.api_key.trim())\n    }\n}\n","sourceCodeStart":1201,"sourceCodeEnd":1237,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/protocol_proxy.rs#L1201-L1237","documentation":"validate_upstream is the shared pre-flight check for proxied upstream requests: it requires relay.base_url to be non-empty before any request is forwarded. An empty URL means there is no upstream to send to, so it bails with this message. Called before building/issuing the reqwest request.","triggerScenarios":"Any proxy request path that calls validate_upstream while the active relay profile's base_url is empty or whitespace after trim.","commonSituations":"Freshly created profile without an upstream URL; base_url cleared in the manager UI; hand-edited settings file missing base_url for the active profile.","solutions":["Set the 上游 Base URL (base_url) in the active relay profile to a valid https:// endpoint","Inspect the settings file to confirm base_url is present on the active profile","Re-apply the relay profile after editing"],"exampleFix":"// before\nbase_url = \"\"\n// after\nbase_url = \"https://api.openai.com\"","handlingStrategy":"validation","validationCode":"if relay.base_url.trim().is_empty() { return Err(\"upstream base url is empty\"); }","typeGuard":null,"tryCatchPattern":"match send_proxied_request(...) {\n    Err(e) if e.to_string().contains(\"上游 Base URL 不能为空\") => eprintln!(\"请在当前中转填写上游 Base URL: {e}\"),\n    other => other?,\n}","preventionTips":["Require base_url at profile creation time","Run a pre-flight validate_upstream check in callers","Detect blank fields after settings migrations"],"tags":["config","validation","url","empty"],"backgroundTag":"empty-required-field","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"}