BigPizzaV3/CodexPlusPlus · error
无效的市场主题下载文件名
Error message
无效的市场主题下载文件名
What it means
`market_download_path` constructs the on-disk path for a downloaded market theme asset (`<state>/dream-skin/market/downloads/<id>.<ext>`) and validates both parts first: the theme id must pass `valid_theme_id` and the file extension must be one of `png`, `jpg`, `gif`, `bmp`, `webp`. Anything else is rejected to prevent path traversal and writing non-image data under the downloads directory.
Solutions
- Check the theme's asset URLs in the manifest: ensure they end in one of png/jpg/gif/bmp/webp and fix the manifest or server file naming otherwise.
- Verify the theme id passes the app's id rules (alphanumeric with `-`, `_`, `.` segments, no traversal); correct the manifest id if it was hand-edited.
- If the server serves a valid image under an unsupported extension (e.g. `jpeg`), rename/republish it with a canonical extension.
- If a genuinely new format must be supported, extend the `matches!(extension, ...)` allowlist in `market_download_path` upstream.
Example fix
// manifest theme asset URL // before "image": "assets/banner.jpeg" // after "image": "assets/banner.jpg"
Defensive patterns
Strategy: validation
Validate before calling
fn valid_download_name(id: &str, ext: &str) -> bool {
let id_ok = !id.is_empty()
&& id.bytes().all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.'))
&& !id.contains('..');
id_ok && matches!(ext, "png" | "jpg" | "gif" | "bmp" | "webp")
} Type guard
fn is_allowed_image_ext(url: &str) -> Option<&str> {
let ext = url.rsplit('.').next()?;
matches!(ext, "png" | "jpg" | "gif" | "bmp" | "webp").then_some(ext)
} Try / catch
match install_market_theme_from_base(...).await {
Err(e) if e.to_string().contains("下载文件名") => {
eprintln!("theme asset id/extension rejected; check manifest URLs");
}
other => other?,
} Prevention
- Publish theme assets only with canonical extensions png/jpg/gif/bmp/webp (use .jpg not .jpeg)
- Validate theme ids against the same charset rules before adding them to a manifest
- Reject absolute or traversal-style ids at manifest authoring time
- Treat this error as a sign of a tampered manifest and refetch from a trusted source
When it happens
Trigger: `install_market_theme_from_base` calls `market_download_path` with a theme id that fails `valid_theme_id` (empty, wrong charset, too long) or a URL/manifest extension outside the allowed image set (e.g. `zip`, `svg`, `jpeg`, ``, or an extension containing path characters).
Common situations: A market manifest advertising a theme asset with an unexpected extension (`svg`, `webp2`, `jpeg`); a manifest theme id that was hand-edited to contain `/`, `..`, or non-ASCII characters; a compromised or buggy market server listing malicious ids.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- invalid Dream Skin destination name
- Backup source database is not an allowed local storage path
- built-in Dream Skin theme cannot be deleted
- built-in Dream Skin theme is read-only
- current Dream Skin theme cannot be deleted
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/d2e8bc9c561a6b5a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_market.rs:326
});
}
let records: MarketInstallRecords = serde_json::from_slice(&std::fs::read(path)?)?;
if records.schema_version != market_schema_version() {
bail!("不支持的主题市场安装记录版本");
}
Ok(records)
}
fn record_market_install(state_dir: &Path, id: &str, version: &str) -> anyhow::Result<()> {
let mut records = read_install_records(state_dir)?;
records.themes.insert(id.to_string(), version.to_string());
let bytes = serde_json::to_vec_pretty(&records)?;
crate::settings::atomic_write(&state_dir.join(MARKET_INSTALLS_FILE), &bytes)
}
fn market_download_path(state_dir: &Path, id: &str, extension: &str) -> anyhow::Result<PathBuf> {
if !valid_theme_id(id) || !matches!(extension, "png" | "jpg" | "gif" | "bmp" | "webp") {
bail!("无效的市场主题下载文件名");
}
Ok(state_dir
.join("dream-skin/market/downloads")
.join(format!("{id}.{extension}")))
}
fn market_asset_url(base_url: &str, relative: &str) -> anyhow::Result<String> {
validate_market_path(relative)?;
let base = reqwest::Url::parse(base_url).context("主题市场基础地址无效")?;
let joined = base.join(relative).context("主题市场资源地址无效")?;
if joined.scheme() != base.scheme() || joined.host_str() != base.host_str() {
bail!("主题市场资源地址越界");
}
Ok(joined.to_string())
}
fn validate_market_path(value: &str) -> anyhow::Result<()> {
if value.is_empty()View on GitHub (pinned to b1ed92e5e4)