{"record":{"id":"f7d2ffc082a39f1b","repo":"nikivdev/code","slug":"invalid-workspace-path","errorCode":null,"errorMessage":"invalid workspace path","messagePattern":"invalid workspace path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ext.rs","lineNumber":286,"sourceCode":"        }\n    }\n\n    let workspaces = jj_workspace_list(&repo_root).unwrap_or_default();\n    if let Some(existing_path) = workspaces.get(&workspace) {\n        return Ok(PathBuf::from(existing_path));\n    }\n\n    let base = workspace_base(&repo_root)?;\n    fs::create_dir_all(&base).with_context(|| format!(\"failed to create {}\", base.display()))?;\n    let workspace_path = base.join(&workspace);\n    jj_run_in(\n        &repo_root,\n        &[\n            \"workspace\",\n            \"add\",\n            workspace_path\n                .to_str()\n                .ok_or_else(|| anyhow::anyhow!(\"invalid workspace path\"))?,\n            \"--name\",\n            &workspace,\n        ],\n    )?;\n\n    println!(\n        \"Created jj workspace {} at {}\",\n        workspace,\n        workspace_path.display()\n    );\n    Ok(workspace_path)\n}\n\nfn workspace_name_for_project(project_root: &Path) -> Result<String> {\n    let home = std::env::var(\"HOME\").ok();\n    let mut relative = None;\n    if let Some(home) = home.as_deref() {\n        if let Ok(stripped) = project_root.strip_prefix(home) {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ext.rs#L268-L304","documentation":"In `prepare_source_workspace` (called from `import_external_path`), the CLI converts the computed workspace path to a string with `Path::to_str()` before passing it as an argument to the internal `workspace add` command. `to_str()` returns `None` for non-UTF-8 paths, and the code surfaces this as 'invalid workspace path'.","triggerScenarios":"Importing an external path whose resolved repository/workspace path contains invalid UTF-8 bytes (e.g. from a filesystem allowing arbitrary byte sequences in names), so `workspace_path.to_str()` is `None`.","commonSituations":"Repositories or checkouts with non-UTF-8 file/directory names (common with legacy encodings or files created on other OSes); paths built from raw bytes on Linux; NFS/external drives with unusual naming.","solutions":["Rename the offending directories/files to valid UTF-8 names before importing","Re-clone or re-copy the external repository into a path with standard UTF-8 names","Import from a parent directory whose path to the repo root is plain ASCII/UTF-8"],"exampleFix":"// before\nmv 'repos/caf$\\xe9' repos/cafe\nf ext import repos/cafe\n// after\nf ext import repos/cafe   # succeeds: path is valid UTF-8","handlingStrategy":"validation","validationCode":"fn ensure_utf8_path(p: &std::path::Path) -> anyhow::Result<&str> {\n    p.to_str().ok_or_else(|| anyhow::anyhow!(\"path is not valid UTF-8: {}\", p.display()))\n}","typeGuard":"fn is_valid_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }","tryCatchPattern":null,"preventionTips":["Keep repo and workspace paths UTF-8 clean","Re-clone sources with non-UTF-8 filenames before importing","Avoid importing paths assembled from raw OS bytes"],"tags":["filesystem","path","encoding"],"backgroundTag":"invalid-path-encoding","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}