{"record":{"id":"deffc367da3eb5d0","repo":"BigPizzaV3/CodexPlusPlus","slug":"openai-responses-api","errorCode":null,"errorMessage":"OpenAI 会话身份仅支持 Responses API","messagePattern":"OpenAI 会话身份仅支持 Responses API","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/relay_config.rs","lineNumber":408,"sourceCode":"\npub fn apply_relay_config_to_home_with_session_provider(\n    home: &Path,\n    base_url: &str,\n    bearer_token: &str,\n    protocol: RelayProtocol,\n    proxy_port: u16,\n    session_provider: RelaySessionProvider,\n) -> anyhow::Result<RelayApplyResult> {\n    let base_url = base_url.trim();\n    if base_url.is_empty() {\n        anyhow::bail!(\"中转 Base URL 不能为空\");\n    }\n    let bearer_token = bearer_token.trim();\n    if bearer_token.is_empty() {\n        anyhow::bail!(\"中转 Key 不能为空\");\n    }\n    if session_provider == RelaySessionProvider::Openai && protocol != RelayProtocol::Responses {\n        anyhow::bail!(\"OpenAI 会话身份仅支持 Responses API\");\n    }\n    let codex_base_url = codex_base_url_for_protocol(base_url, protocol, proxy_port);\n    let updated = upsert_model_provider_config_with_session_provider(\n        \"\",\n        &codex_base_url,\n        bearer_token,\n        true,\n        session_provider,\n    )?;\n    let auth_contents = serde_json::to_string_pretty(&json!({\n        \"OPENAI_API_KEY\": bearer_token\n    }))?;\n    let backup_path =\n        write_codex_live_atomic(home, Some(&updated), Some(auth_contents.as_bytes()))?;\n    let status = relay_config_status_from_home(home);\n    Ok(RelayApplyResult {\n        config_path: status.config_path,\n        backup_path,","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/relay_config.rs#L390-L426","documentation":"Thrown by `apply_relay_config_to_home_with_session_provider` in relay_config.rs when `session_provider` is `RelaySessionProvider::Openai` but `protocol` is not `RelayProtocol::Responses`. OpenAI session identity (session-scoped auth semantics) is only implemented for the Responses API wire protocol; Chat/other protocols cannot carry it, so the combination is rejected as unsupported.","triggerScenarios":"Calling `apply_relay_config_to_home_with_protocol` with `session_provider = RelaySessionProvider::Openai` and `protocol = RelayProtocol::Chat` (or any non-Responses variant); bails at relay_config.rs:408.","commonSituations":"User selected 'OpenAI session identity' in the manager UI while the profile's wire protocol was Chat; a migrated profile kept the old protocol after the session-provider option was introduced; code combined defaults (Chat protocol) with an Openai session provider constant.","solutions":["Switch the profile's protocol to RelayProtocol::Responses when using the Openai session provider.","Or change session_provider to a non-Openai value (e.g. the default) if Responses API is not available.","Add a UI-level constraint so selecting Openai session identity forces/permits only Responses protocol."],"exampleFix":"// before\napply_relay_config_to_home_with_protocol(home, url, key, RelayProtocol::Chat, port, RelaySessionProvider::Openai).await?;\n// after\napply_relay_config_to_home_with_protocol(home, url, key, RelayProtocol::Responses, port, RelaySessionProvider::Openai).await?;","handlingStrategy":"validation","validationCode":"if sp == RelaySessionProvider::Openai && proto != RelayProtocol::Responses {\n    return Err(anyhow::anyhow!(\"OpenAI 会话身份仅支持 Responses API，请切换协议或会话身份\"));\n}","typeGuard":"fn openai_session_allowed(sp: RelaySessionProvider, p: RelayProtocol) -> bool {\n    sp != RelaySessionProvider::Openai || p == RelayProtocol::Responses\n}","tryCatchPattern":"match apply_relay_config_to_home_with_protocol(home, url, key, proto, port, sp).await {\n    Ok(r) => Ok(r),\n    Err(e) if e.to_string().contains(\"仅支持 Responses API\") => {\n        eprintln!(\"请在配置中将协议切换为 Responses，或改用默认会话身份\");\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Constrain the UI so selecting Openai session identity auto-selects/locks Responses protocol.","Model the combination in the type system (constructor that only accepts valid pairs).","Add a unit test asserting the invalid combination is rejected."],"tags":["validation","relay-config","incompatible-options","protocol"],"backgroundTag":"conflicting-config-options","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"}