BigPizzaV3/CodexPlusPlus · error
theme.json.name 无效
Error message
theme.json.name 无效
What it means
validate_theme rejects theme.json when the name field, though present and a string, fails safe_manifest_text(name, 1, 80, false) — i.e. it is empty, longer than 80 characters, or contains disallowed characters (e.g. control characters or newlines). The library enforces display-text hygiene to keep theme names safe to render.
Solutions
- Set theme.json.name to a non-empty string of at most 80 characters
- Strip control characters, newlines, and other unsafe text from name
- Trim whitespace so the name is not effectively empty
- Re-run validation after editing to confirm the value passes
Example fix
// before "name": "" // or a 200-char name // after "name": "Midnight codex"
Defensive patterns
Strategy: validation
Validate before calling
const name = theme.name;
if (typeof name !== "string" || name.trim().length === 0 || name.length > 80 || /[\u0000-\u001f]/.test(name)) {
throw new Error("theme.json.name must be 1-80 safe characters");
} Type guard
function isValidThemeName(v) {
return typeof v === "string" && v.length >= 1 && v.length <= 80 &&
!/[\u0000-\u001f]/.test(v);
} Prevention
- Keep theme names under 80 characters, trimmed
- Strip control characters and newlines before writing theme.json
- Validate name in CI before packaging
When it happens
Trigger: Calling validate_and_read_package with a theme.json whose name is an empty string, exceeds 80 characters, or contains characters rejected by safe_manifest_text (control chars, newlines, etc.).
Common situations: Leaving name as "" in a template; pasting a long title with a trailing newline; including emoji/control characters or HTML in the theme name; copying a name over 80 chars from a marketing document.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- theme.json. 无效
- theme.json 的链接或外观字段无效
- theme.json.colors 字段无效
- theme.json.colors 缺少
- theme.json 与 manifest 身份或背景图不一致
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/3037873c6f4bdd74.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:1022
|| object
.keys()
.any(|key| !REQUIRED.contains(&key.as_str()) && !OPTIONAL.contains(&key.as_str()))
{
bail!("theme.json 包含缺失或不支持的字段");
}
if object.get("schemaVersion").and_then(Value::as_u64) != Some(1)
|| object.get("id").and_then(Value::as_str) != Some(manifest.theme_id.as_str())
|| object.get("name").and_then(Value::as_str).is_none()
|| object.get("image").and_then(Value::as_str) != Some(image_name)
{
bail!("theme.json 与 manifest 身份或背景图不一致");
}
if object
.get("name")
.and_then(Value::as_str)
.is_some_and(|name| !safe_manifest_text(name, 1, 80, false))
{
bail!("theme.json.name 无效");
}
for key in [
"brandSubtitle",
"tagline",
"projectPrefix",
"projectLabel",
"statusText",
"quote",
"promoTitle",
"promoSub",
] {
if object.get(key).is_some_and(|value| {
value
.as_str()
.is_none_or(|text| !safe_manifest_text(text, 0, 120, false))
}) {
bail!("theme.json.{key} 无效");
}View on GitHub (pinned to b1ed92e5e4)