{"record":{"id":"1803808d7b43da04","repo":"affaan-m/ECC","slug":"stderr","errorCode":null,"errorMessage":"{stderr}","messagePattern":"\\{stderr\\}","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/worktree/mod.rs","lineNumber":1493,"sourceCode":"    Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())\n}\n\nfn validate_branch_name(repo_root: &Path, branch: &str) -> Result<()> {\n    let output = Command::new(\"git\")\n        .arg(\"-C\")\n        .arg(repo_root)\n        .args([\"check-ref-format\", \"--branch\", branch])\n        .output()\n        .context(\"Failed to validate worktree branch name\")?;\n\n    if output.status.success() {\n        Ok(())\n    } else {\n        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();\n        if stderr.is_empty() {\n            anyhow::bail!(\"branch name is not a valid git ref\");\n        } else {\n            anyhow::bail!(\"{stderr}\");\n        }\n    }\n}\n\nfn parse_git_status_entry(line: &str) -> Option<GitStatusEntry> {\n    if line.len() < 4 {\n        return None;\n    }\n    let bytes = line.as_bytes();\n    let index_status = bytes[0] as char;\n    let worktree_status = bytes[1] as char;\n    let raw_path = line.get(3..)?.trim();\n    if raw_path.is_empty() {\n        return None;\n    }\n    let display_path = raw_path.to_string();\n    let normalized_path = raw_path\n        .split(\" -> \")","sourceCodeStart":1475,"sourceCodeEnd":1511,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/worktree/mod.rs#L1475-L1511","documentation":"Same validation site as the generic invalid-ref error: when `validate_branch_name`'s underlying git check fails but git DOES print a message, the library bails with that raw `{stderr}`. So this error carries git's actual explanation, e.g. 'fatal: 'a..b' is not a valid branch name'.","triggerScenarios":"Calling branch creation/validation with a name git explicitly rejects, where stderr is non-empty: forbidden sequences ('..'), leading/trailing slashes, 'refs/heads/' prefixes, reserved names.","commonSituations":"Names pasted with 'origin/' or 'refs/heads/' prefixes; branch names containing '..' from version-range strings; unicode or emoji names on filesystems that reject them.","solutions":["Read the stderr in the error message — it names the exact rule violated","Strip 'refs/heads/' or remote prefixes before validating ('name.rsplit_once(\"/\")' is not enough; use the last segment)","Remove invalid sequences like '..' and '@{' and re-validate","Follow up with 'git check-ref-format' locally to confirm the sanitized name passes"],"exampleFix":"// before\nlet name = \"feature/a..b\";\nvalidate_branch_name(&root, name)?;\n// after\nlet name = name.trim_start_matches(\"refs/heads/\").replace(\"..\", \"-\");\nvalidate_branch_name(&root, &name)?;","handlingStrategy":"validation","validationCode":"let check = Command::new(\"git\")\n    .args([\"check-ref-format\", \"--branch\", name])\n    .output()?;\nif !check.status.success() {\n    let msg = String::from_utf8_lossy(&check.stderr).trim().to_string();\n    anyhow::bail!(\"invalid branch name: {msg}\");\n}","typeGuard":"fn is_valid_git_ref(name: &str) -> bool {\n    !name.trim_start_matches(\"refs/heads/\").is_empty()\n        && !name.contains(\"..\")\n        && !name.contains(\"@{\")\n        && !name.starts_with('/')\n        && !name.ends_with('/')\n        && !name.contains(\" \")\n}","tryCatchPattern":"match validate_branch_name(&root, name) {\n    Ok(()) => (),\n    Err(e) => {\n        // error body is git's own stderr — surface it verbatim to the user\n        eprintln!(\"git rejected branch name: {e}\");\n        return Err(e);\n    }\n}","preventionTips":["Strip refs/heads/ and remote prefixes before validating names","Pre-validate names with git check-ref-format so git's own message is shown","Reject or transform '..' sequences from version-like inputs","Log the raw name alongside the error for debugging config-driven names"],"tags":["git","branch-name","validation"],"backgroundTag":"invalid-identifier-format","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"}