{"record":{"id":"539991d139025550","repo":"affaan-m/ECC","slug":"worktree-branch-prefix-cannot-be-empty","errorCode":null,"errorMessage":"worktree_branch_prefix cannot be empty","messagePattern":"worktree_branch_prefix cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/worktree/mod.rs","lineNumber":163,"sourceCode":"        );\n    }\n\n    Ok(info)\n}\n\npub fn sync_shared_dependency_dirs(worktree: &WorktreeInfo) -> Result<Vec<String>> {\n    let repo_root = base_checkout_path(worktree)?;\n    sync_shared_dependency_dirs_in_repo(worktree, &repo_root)\n}\n\npub(crate) fn branch_name_for_session(\n    session_id: &str,\n    cfg: &Config,\n    repo_root: &Path,\n) -> Result<String> {\n    let prefix = cfg.worktree_branch_prefix.trim().trim_matches('/');\n    if prefix.is_empty() {\n        anyhow::bail!(\"worktree_branch_prefix cannot be empty\");\n    }\n\n    let branch = format!(\"{prefix}/{session_id}\");\n    validate_branch_name(repo_root, &branch).with_context(|| {\n        format!(\n            \"Invalid worktree branch '{branch}' derived from prefix '{}' and session id '{session_id}'\",\n            cfg.worktree_branch_prefix\n        )\n    })?;\n\n    Ok(branch)\n}\n\n/// Remove a worktree and its branch.\npub fn remove(worktree: &WorktreeInfo) -> Result<()> {\n    let repo_root = match base_checkout_path(worktree) {\n        Ok(path) => path,\n        Err(error) => {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/worktree/mod.rs#L145-L181","documentation":"branch_name_for_session derives the worktree branch as `<prefix>/<session_id>` after trimming whitespace and trailing slashes from cfg.worktree_branch_prefix. If the prefix is empty (or only slashes/whitespace), it bails rather than producing an invalid branch like '/session-id'.","triggerScenarios":"Constructing a Config with worktree_branch_prefix set to \"\", \"   \", \"/\", or \"///\" and calling create_for_session.","commonSituations":"A config file where the prefix key is present but blank; environment-driven config where the prefix variable was unset and defaulted to empty; a YAML/TOML value of \"\" instead of a sensible default like \"ecc\".","solutions":["Set worktree_branch_prefix to a non-empty value (e.g. \"ecc\" or \"session\") in your config","Add a startup config validation that rejects empty prefixes before any session is created","Use a fallback default in code when the field is missing: prefix = if cfg_prefix.is_empty() { \"ecc\" } else { cfg_prefix }"],"exampleFix":"// before\nworktree_branch_prefix = \"\"\n// after\nworktree_branch_prefix = \"ecc\"","handlingStrategy":"validation","validationCode":"// Validate config at startup\nlet prefix = cfg.worktree_branch_prefix.trim().trim_matches('/');\nif prefix.is_empty() {\n    return Err(anyhow::anyhow!(\"worktree_branch_prefix must be a non-empty branch prefix, e.g. 'ecc'\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide a sensible default prefix in config templates (e.g. worktree_branch_prefix = \"ecc\")","Validate the full config once at startup instead of failing on first session creation","Never allow whitespace-only or slash-only prefix values in config tooling"],"tags":["config","git","validation","rust"],"backgroundTag":"invalid-config-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}