{"record":{"id":"2382ba27aa636aa1","repo":"FuelLabs/sway","slug":"invalid-folder-name","errorCode":null,"errorMessage":"invalid folder name","messagePattern":"invalid folder name","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"forc-pkg/src/source/git/mod.rs","lineNumber":667,"sourceCode":"            }\n        }\n        Ok(())\n    })?;\n    Ok(found_local_repo)\n}\n\n/// Search local checkouts directory and apply the given function. This is used for iterating over\n/// possible options of a given package.\nfn with_search_checkouts<F>(checkouts_dir: PathBuf, package_name: &str, mut f: F) -> Result<()>\nwhere\n    F: FnMut(SourceIndex, PathBuf) -> Result<()>,\n{\n    for entry in fs::read_dir(checkouts_dir)? {\n        let entry = entry?;\n        let folder_name = entry\n            .file_name()\n            .into_string()\n            .map_err(|_| anyhow!(\"invalid folder name\"))?;\n        if folder_name.starts_with(package_name) {\n            // Search if the dir we are looking starts with the name of our package\n            for repo_dir in fs::read_dir(entry.path())? {\n                // Iterate over all dirs inside the `name-***` directory and try to open repo from\n                // each dirs inside this one\n                let repo_dir = repo_dir\n                    .map_err(|e| anyhow!(\"Cannot find local repo at checkouts dir {}\", e))?;\n                if repo_dir.file_type()?.is_dir() {\n                    // Get the path of the current repo\n                    let repo_dir_path = repo_dir.path();\n                    // Get the index file from the found path\n                    if let Ok(index_file) = fs::read_to_string(repo_dir_path.join(\".forc_index\")) {\n                        let index = serde_json::from_str(&index_file)?;\n                        f(index, repo_dir_path)?;\n                    }\n                }\n            }\n        }","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/source/git/mod.rs#L649-L685","documentation":"While scanning the local git checkouts directory to find offline candidates, forc converts each directory name to a String. On systems with non-UTF-8 filenames, into_string() fails and this generic 'invalid folder name' error aborts the whole scan.","triggerScenarios":"Any file or directory under ~/.forc/git/checkouts whose name is not valid UTF-8 - created by misbehaving tooling, odd archive extraction, or manual filesystem operations.","commonSituations":"Machines where some tool created directory names with invalid byte sequences; restoring caches from archives with exotic names.","solutions":["List the checkouts dir and remove/rename the offending non-UTF-8 entries (inspect with `ls -b` to reveal escapes)","If the failing entry is unclear, temporarily move subdirectories aside until the scan passes","Avoid tools that create non-UTF-8 paths inside the forc cache"],"exampleFix":"# remove non-ASCII/non-UTF-8 entries in the checkouts dir (bash)\nfind \"$HOME/.forc/git/checkouts\" -mindepth 1 -maxdepth 1 \\\n  -exec bash -c 'p=\"$1\"; case \"${p##*/}\" in *[![:print:]]*) rm -rf \"$p\";; esac' _ {} \\;","handlingStrategy":"validation","validationCode":"fn checkouts_are_utf8_clean(checkouts: &Path) -> anyhow::Result<()> {\n    for entry in std::fs::read_dir(checkouts)? {\n        let entry = entry?;\n        if entry.file_name().into_string().is_err() {\n            anyhow::bail!(\"non-UTF-8 cache entry: {:#?}\", entry.path());\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep ~/.forc managed only by forc itself","Audit cache directories after restoring them from archives","Fail fast with a precise path instead of the generic library message"],"tags":["filesystem","utf-8","offline","cache"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}