BigPizzaV3/CodexPlusPlus · error · anyhow::Error
不是 Codex++ 会话导入链接
Error message
不是 Codex++ 会话导入链接
What it means
save_pending_session_share_from_protocol_url first parses the codexpp:// protocol URL, then requires its host to be share.codexpp.cc or codexpp-share.pages.dev (SHARE_HOSTS) with a fragment. This bail is the shape guard: the URL is not a recognized Codex++ session-import link, so no pending share is stored.
Solutions
- Pass the full codexplusplus://session?url=... link produced by the share dialog
- If you only have the https share URL, call load_pending_session_share or import_shared_session_url directly instead
- Check the OS URL-handler registration is intact so the scheme survives round-trips
Example fix
// before
save_pending_session_share_from_protocol_url("https://share.codexpp.cc/s/abc#key")?;
// after
save_pending_session_share_from_protocol_url("codexplusplus://session?url=https%3A%2F%2Fshare.codexpp.cc%2Fs%2Fabc%23key")?; Defensive patterns
Strategy: type-guard
Validate before calling
fn is_codexpp_protocol_url(url: &str) -> bool {
reqwest::Url::parse(url).map(|u| u.scheme() == "codexplusplus" && u.host_str() == Some("session")).unwrap_or(false)
} Type guard
fn as_session_protocol_url(url: &str) -> Option<String> {
let u = reqwest::Url::parse(url).ok()?;
(u.scheme() == "codexplusplus" && u.host_str() == Some("session")).then(|| url.to_string())
} Try / catch
match save_pending_session_share_from_protocol_url(raw) {
Ok(id) => proceed(id),
Err(e) if e.to_string().contains("会话导入链接") => prompt_user_to_use_protocol_link(),
Err(e) => show_error(e),
} Prevention
- Register and use the codexplusplus:// URL handler end-to-end
- Distinguish between https share links and protocol wrapper links in the UI
- URL-encode the inner https share URL inside the protocol link
When it happens
Trigger: Calling save_pending_session_share_from_protocol_url with a URL whose scheme is not "codexplusplus" or whose host is not "session", e.g. a plain https share link passed directly.
Common situations: Pasting the underlying https://share.codexpp.cc/... link into the importer instead of the codexplusplus://session?url=... wrapper; OS handlers mangling the custom scheme; using an old scheme format.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- API 地址须使用 HTTPS,且不含账号、密码、查询参数或片段
- 链接缺少解密密钥。请使用完整的分享链接。
- Base URL 不能为空
- 上游 Base URL 不能为空
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/f828d7398401168a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:18
use aes_gcm::{Aes256Gcm, KeyInit, Nonce, aead::Aead};
use anyhow::{Context, bail};
use base64::Engine;
use rusqlite::Connection;
use serde_json::{Value, json};
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH};
use uuid::Uuid;
const MAX_ROLLOUT_BYTES: usize = 16 * 1024 * 1024;
const SHARE_HOSTS: &[&str] = &["share.codexpp.cc", "codexpp-share.pages.dev"];
pub fn save_pending_session_share_from_protocol_url(url: &str) -> anyhow::Result<String> {
let parsed = reqwest::Url::parse(url).context("会话导入链接格式无效")?;
if parsed.scheme() != "codexplusplus" || parsed.host_str() != Some("session") {
bail!("不是 Codex++ 会话导入链接");
}
let share_url = parsed
.query_pairs()
.find(|(key, _)| key == "url")
.map(|(_, value)| value.into_owned())
.context("会话导入链接缺少分享 URL")?;
validate_share_url(&share_url)?;
let path = crate::paths::default_pending_session_share_path();
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
fs::write(&path, format!("{share_url}\n"))?;
Ok(share_url)
}
pub fn load_pending_session_share() -> anyhow::Result<Option<String>> {
let path = crate::paths::default_pending_session_share_path();
if !path.exists() {View on GitHub (pinned to b1ed92e5e4)