{"record":{"id":"98f8969915d8d154","repo":"BigPizzaV3/CodexPlusPlus","slug":"dreamskin","errorCode":null,"errorMessage":"DreamSkin 主题版本与请求不一致","messagePattern":"DreamSkin 主题版本与请求不一致","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":157,"sourceCode":"pub async fn install_community_theme(\n    state_dir: &Path,\n    version_id: &str,\n) -> anyhow::Result<DreamSkinThemeSummary> {\n    validate_version_id(version_id)?;\n    let client = community_http_client(Duration::from_secs(120))?;\n    let metadata_url = format!(\"{COMMUNITY_API_ORIGIN}/v1/themes/{version_id}\");\n    let metadata_bytes = download_limited(\n        &client,\n        &metadata_url,\n        METADATA_BYTES_LIMIT,\n        \"application/json\",\n    )\n    .await?;\n    let metadata: DreamSkinCommunityTheme =\n        serde_json::from_slice(&metadata_bytes).context(\"DreamSkin 主题元数据不是有效 JSON\")?;\n    validate_community_theme(&metadata)?;\n    if metadata.id != version_id {\n        bail!(\"DreamSkin 主题版本与请求不一致\");\n    }\n    if !metadata.apply_compatible {\n        bail!(\"该主题是旧格式，只支持在线预览或手动下载\");\n    }\n\n    let download_url = format!(\"{COMMUNITY_API_ORIGIN}/v1/themes/{version_id}/download\");\n    let package = download_limited(\n        &client,\n        &download_url,\n        metadata.package_bytes,\n        \"application/zip\",\n    )\n    .await?;\n    if package.len() != metadata.package_bytes {\n        bail!(\"DreamSkin 主题包实际大小与审核元数据不一致\");\n    }\n    let actual_sha = format!(\"{:x}\", Sha256::digest(&package));\n    if !actual_sha.eq_ignore_ascii_case(&metadata.package_sha256) {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L139-L175","documentation":"install_community_theme fetches a theme version's metadata from the community API and validates it. After schema validation, it checks that the returned metadata.id equals the requested version_id; if the server returns metadata for a different version, the install is aborted. This protects against CDN caches or API routing serving the wrong theme version.","triggerScenarios":"Calling install_community_theme(state_dir, version_id) where the GET /v1/themes/{version_id} response parses and passes validate_community_theme but carries an id field different from version_id — e.g. a stale/redirecting endpoint, alias resolution, or server bug returning another version's record.","commonSituations":"Server-side cache serving a different version record after an upload replaced a version id; a CDN edge with inconsistent data; passing a theme id instead of a version id to install_community_theme; community API routing bugs after re-publishing themes.","solutions":["Retry the install — a transient cache may resolve and return the correct version metadata.","Verify the version_id was copied from the catalog/link exactly (not the parent theme id).","Check the community API directly: GET /v1/themes/{version_id} and compare the returned id with your request.","Clear/refresh any cache between client and API, or re-fetch the community catalog to get current valid version ids."],"exampleFix":"// before: possibly stale id\ninstall_community_theme(&state_dir, \"old-version-id\").await?;\n// after: re-fetch catalog and use the fresh id\nlet catalog = fetch_community_catalog().await?;\nlet id = &catalog.items[0].latest_version_id;\ninstall_community_theme(&state_dir, id).await?;","handlingStrategy":"validation","validationCode":"// fetch metadata yourself and confirm the id before installing\nlet meta: DreamSkinCommunityTheme = http_get(format!(\"{ORIGIN}/v1/themes/{id}\")).json().await?;\nif meta.id != id { return Err(\"server returned a different version\".into()); }","typeGuard":null,"tryCatchPattern":"match install_community_theme(&state_dir, version_id).await {\n    Err(e) if e.to_string().contains(\"版本与请求不一致\") => {\n        // re-fetch catalog, resolve fresh version id, retry once\n    }\n    other => other?,\n}","preventionTips":["Always take version ids directly from a freshly fetched community catalog, not cached links.","Do not confuse theme ids with version ids.","After server-side re-uploads, re-fetch metadata before installing."],"tags":["api","integrity-check","rust","network"],"backgroundTag":"unexpected-api-response-shape","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"}