BigPizzaV3/CodexPlusPlus · error

市场主题 的来源地址协议无效

Error message

市场主题 {} 的来源地址协议无效

What it means

While validating a market theme manifest entry, `validate_market_theme` parses the theme's `source_url` and rejects it if the URL scheme is not exactly `http` or `https`. The library throws this to enforce that theme source links point at a fetchable web resource, blocking schemes like `ftp`, `file`, or `data:` that could be unsafe or unsupported by the download client.

Solutions

  1. Fix the theme's `source_url` in the market manifest so it starts with `https://` (preferred) or `http://`.
  2. If you control the market server, re-publish the manifest with corrected source URLs and refresh the market index.
  3. If you maintain a cached copy, delete the market cache file in the state dir (`dream-skin/market` cache) so a fresh manifest is fetched after the fix.
  4. If you believe the scheme is legitimate (e.g. an internal mirror), the upstream code must be extended to allowlist that scheme in the `matches!(source.scheme(), "http" | "https")` check.

Example fix

// manifest theme entry
// before
"source_url": "ftp://themes.example.com/skin-v1.zip"
// after
"source_url": "https://themes.example.com/skin-v1.zip"
Defensive patterns

Strategy: validation

Validate before calling

fn has_web_scheme(url: &str) -> bool {
    reqwest::Url::parse(url)
        .map(|u| matches!(u.scheme(), "http" | "https"))
        .unwrap_or(false)
}
// before installing: assert!(has_web_scheme(&theme.source_url));

Type guard

fn is_http_url(s: &str) -> bool {
    matches!(reqwest::Url::parse(s).ok().as_ref().map(|u| u.scheme()), Some("http") | Some("https"))
}

Try / catch

match install_market_theme_from_base(...).await {
    Err(e) if e.to_string().contains("协议无效") => eprintln!("theme source_url must be http(s): {e}"),
    Err(e) => eprintln!("install failed: {e}"),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: A manifest theme whose `source_url` parses as a valid URL but has a scheme other than http/https (e.g. `ftp://host/theme.zip`, `file:///path`, `data:text/plain,...`). Raised by `validate_market_theme`, which is called from `install_market_theme_from_base` and `validate_manifest` (i.e. both when loading the market index and when installing a theme).

Common situations: Manifest authors hand-editing JSON and typing a wrong scheme; a market server serving themes whose `source_url` uses a custom/internal scheme; copying an `ftp://` or local-file link as the source; typos like `htttp://` that still parse as a URL with an unknown scheme.

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


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/912cdc61993008e9. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:230

    ] {
        if value.trim().is_empty() || value.len() > limit {
            bail!("市场主题 {} 的{}无效", theme.id, label);
        }
    }
    if theme.description.len() > 500 || theme.tags.len() > 12 {
        bail!("市场主题 {} 的描述或标签数量超过限制", theme.id);
    }
    if theme
        .tags
        .iter()
        .any(|tag| tag.trim().is_empty() || tag.len() > 32)
    {
        bail!("市场主题 {} 包含无效标签", theme.id);
    }
    let source = reqwest::Url::parse(&theme.source_url)
        .with_context(|| format!("市场主题 {} 的来源地址无效", theme.id))?;
    if !matches!(source.scheme(), "http" | "https") {
        bail!("市场主题 {} 的来源地址协议无效", theme.id);
    }
    for path in [&theme.theme, &theme.image, &theme.preview] {
        validate_market_path(path)?;
    }
    validate_sha256(&theme.theme_sha256)?;
    validate_sha256(&theme.image_sha256)?;
    Ok(())
}

fn market_http_client() -> anyhow::Result<reqwest::Client> {
    Ok(reqwest::Client::builder()
        .user_agent(format!(
            "CodexPlusPlus-Themes/{}",
            env!("CARGO_PKG_VERSION")
        ))
        .connect_timeout(Duration::from_secs(8))
        .timeout(Duration::from_secs(30))
        .build()?)

View on GitHub (pinned to b1ed92e5e4)