BigPizzaV3/CodexPlusPlus · error

invalid Dream Skin theme id

Error message

invalid Dream Skin theme id

What it means

load_stored_dream_skin_theme validates the theme id before touching the filesystem: if valid_theme_id(id) fails it bails with "invalid Dream Skin theme id". Because ids become directory names under state_dir/themes, this check blocks path traversal and other unsafe identifiers before any path is joined.

Solutions

  1. Sanitize the id before calling: use only the characters valid_theme_id accepts (alphanumeric/dash style) and trim whitespace
  2. Reject empty ids at the UI/boundary layer before they reach the library
  3. Never build ids from user-controlled paths; strip any '/' or '..' segments
  4. Check upstream docs/tests for the exact valid_theme_id rules and validate input against them early

Example fix

// before
load_stored_dream_skin_theme(&state_dir, &user_input)?;
// after
let id = user_input.trim();
anyhow::ensure!(valid_theme_id(id), "invalid theme id");
load_stored_dream_skin_theme(&state_dir, id)?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_safe_theme_id(id: &str) -> bool {
    !id.is_empty() && !id.contains(['/', '\\', '.', '..']) && id.len() <= 64
}

Type guard

fn valid_theme_id(id: &str) -> bool {
    !id.is_empty() && id.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
}

Try / catch

match load_stored_dream_skin_theme(&state_dir, &id) {
    Ok(draft) => use(draft),
    Err(e) if e.to_string().contains("invalid Dream Skin theme id") => eprintln!("'{}' is not a valid theme id", id),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling load_stored_dream_skin_theme (or any caller passing through it: save/rename/delete, create from image) with an id that fails valid_theme_id — e.g. containing '/' or '..', empty string, illegal characters, or excessive length.

Common situations: Passing raw user input or a URL-decoded name as the id; constructing an id by string concatenation including a path component; deserializing a config whose id field was tampered with; a caller passing a file path instead of an id.

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


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_library.rs:371

    })();
    if let Err(error) = staged {
        let _ = remove_known_theme_directory(&staging);
        return Err(error);
    }
    if let Err(error) = replace_theme_directory(&staging, &target, &suffix) {
        let _ = remove_known_theme_directory(&staging);
        return Err(error);
    }
    let stored = load_stored_dream_skin_theme(state_dir, &config.id)?;
    Ok(summary_from_draft(&stored, false, false))
}

pub fn load_stored_dream_skin_theme(
    state_dir: &Path,
    id: &str,
) -> anyhow::Result<DreamSkinThemeDraft> {
    if !valid_theme_id(id) {
        bail!("invalid Dream Skin theme id");
    }
    let directory = state_dir.join(THEMES_DIR).join(id);
    let metadata = std::fs::symlink_metadata(&directory)
        .with_context(|| format!("Dream Skin theme not found: {id}"))?;
    if !metadata.file_type().is_dir() || metadata.file_type().is_symlink() {
        bail!("Dream Skin theme path is not a safe directory");
    }
    let config_path = directory.join(THEME_CONFIG_FILE);
    let metadata = std::fs::symlink_metadata(&config_path)
        .with_context(|| format!("Dream Skin theme config not found: {id}"))?;
    if !metadata.file_type().is_file()
        || metadata.file_type().is_symlink()
        || metadata.len() > THEME_CONFIG_LIMIT
    {
        bail!("invalid Dream Skin theme config");
    }
    let config: DreamSkinThemeConfig = serde_json::from_slice(&std::fs::read(&config_path)?)?;
    if config.id != id {

View on GitHub (pinned to b1ed92e5e4)