{"record":{"id":"7954d202397c3985","repo":"BigPizzaV3/CodexPlusPlus","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/model_catalog.rs","lineNumber":731,"sourceCode":"        base_url: if profile.upstream_base_url.trim().is_empty() {\n            profile.base_url.trim().to_string()\n        } else {\n            profile.upstream_base_url.trim().to_string()\n        },\n        api_key: profile.api_key.trim().to_string(),\n    };\n    if source.base_url.is_empty() {\n        anyhow::bail!(\"Base URL 不能为空\");\n    }\n    let endpoint = models_endpoint(&source.base_url);\n    let client = crate::http_client::proxied_client(&profile.user_agent)?;\n    let (models, status) = fetch_models_from_source(&client, &source).await;\n    if models.is_empty() {\n        let message = status\n            .get(\"message\")\n            .and_then(Value::as_str)\n            .unwrap_or(\"上游没有返回可用模型\");\n        anyhow::bail!(\"{message}\");\n    }\n    Ok((models, endpoint))\n}\n\nfn preferred_responses_api_status(sources: &[Value]) -> Value {\n    let statuses = sources\n        .iter()\n        .filter_map(|source| source.get(\"responses_api\"))\n        .collect::<Vec<_>>();\n    for wanted in [\"unsupported\", \"supported\", \"failed\"] {\n        if let Some(status) = statuses\n            .iter()\n            .find(|status| status.get(\"status\").and_then(Value::as_str) == Some(wanted))\n        {\n            return (*status).clone();\n        }\n    }\n    responses_api_status(\"unknown\", \"\", \"\")","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/model_catalog.rs#L713-L749","documentation":"After fetching the models list from the upstream /models endpoint, if the list comes back empty the function bails with the message returned by the upstream status payload (its 'message' field), falling back to '上游没有返回可用模型'. The thrown message is dynamic — it relays whatever the upstream API reported about why no models are available.","triggerScenarios":"fetch_relay_profile_model_ids completes an HTTP request but fetch_models_from_source yields zero models — e.g. upstream returned an error status body with a message, an unexpected JSON shape, an empty data array, or a non-200 response whose payload contains 'message'.","commonSituations":"Wrong API key causing upstream auth error with a message; base URL pointing at a non-relay service returning unexpected JSON; upstream outage returning error JSON; relay has no models configured.","solutions":["Inspect the thrown message: it is the upstream's own explanation (auth failure, rate limit, etc.) and fix accordingly.","Verify the API key is valid and has access to the models list.","Check the base URL points to a relay-compatible /v1/models endpoint.","Retry later if the upstream is temporarily unavailable; check upstream service status."],"exampleFix":"// before (server returned {\"message\":\"Invalid API key\"})\nfetch_relay_profile_model_ids(&profile).await?; // bails: Invalid API key\n// after\nprofile.api_key = valid_key.trim().to_string();\nfetch_relay_profile_model_ids(&profile).await?;","handlingStrategy":"retry","validationCode":"// Cannot be pre-validated locally; ensure config sanity first:\n// !profile.upstream_base_url.trim().is_empty() && !profile.api_key.trim().is_empty()","typeGuard":null,"tryCatchPattern":"match fetch_relay_profile_model_ids(&profile).await {\n    Ok((models, endpoint)) => apply(models),\n    Err(e) => {\n        log::warn!(\"fetch models failed: {e}\");\n        if is_transient(&e.to_string()) { backoff_retry(|| fetch_relay_profile_model_ids(&profile), 3).await }\n        else { ui.show_upstream_error(&e.to_string()); }\n    }\n}","preventionTips":["Verify API key validity before calling","Point base_url at a relay-compatible /v1 endpoint","Add exponential backoff retry for transient upstream errors","Log the full upstream status payload for diagnosis","Monitor upstream service health"],"tags":["network","http","upstream","api"],"backgroundTag":"upstream-api-error","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"}