{"record":{"id":"b5d9306f1b634e3d","repo":"gitbutlerapp/gitbutler","slug":"invalid-branch-ref-bytes-in-assignment-request-for-err","errorCode":null,"errorMessage":"Invalid branch_ref_bytes in assignment request for '{}': {err}","messagePattern":"Invalid branch_ref_bytes in assignment request for '(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-hunk-assignment/src/lib.rs","lineNumber":619,"sourceCode":"    }\n}\n\nfn requests_to_assignments(\n    request: Vec<HunkAssignmentRequest>,\n    workspace: &but_graph::Workspace,\n) -> Result<Vec<HunkAssignment>> {\n    let mut assignments = vec![];\n    for req in request {\n        let HunkAssignmentRequest {\n            hunk_header,\n            path_bytes,\n            target,\n        } = req;\n        let branch_ref_bytes = match target {\n            None => None,\n            Some(HunkAssignmentTarget::Branch { branch_ref_bytes }) => Some(\n                gix::refs::FullName::try_from(branch_ref_bytes).map_err(|err| {\n                    anyhow::anyhow!(\n                        \"Invalid branch_ref_bytes in assignment request for '{}': {err}\",\n                        path_bytes.to_str_lossy()\n                    )\n                })?,\n            ),\n            Some(HunkAssignmentTarget::Stack { stack_id }) => Some(\n                workspace\n                    .find_stack_by_id(stack_id)\n                    .and_then(|stack| stack.ref_name())\n                    .map(|ref_name| ref_name.to_owned())\n                    .ok_or_else(|| {\n                        anyhow::anyhow!(\n                            \"Unknown stack_id {stack_id} in assignment request for '{}'\",\n                            path_bytes.to_str_lossy()\n                        )\n                    })?,\n            ),\n        };","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-hunk-assignment/src/lib.rs#L601-L637","documentation":"requests_to_assignments converts user-submitted HunkAssignmentRequest entries into resolvable assignments; when a request targets a Branch, its branch_ref_bytes must parse as a gix::refs::FullName. Malformed ref bytes in the request produce this error naming the file path involved.","triggerScenarios":"Calling assign (crates/but-hunk-assignment/src/lib.rs:619) with a HunkAssignmentTarget::Branch whose branch_ref_bytes is not a valid ref name — clients sending raw bytes that lack the refs/... form.","commonSituations":"SDK/UI clients constructing targets by hand; stale clients from before the bytes-based API; copy-pasted branch names without the refs/heads/ prefix.","solutions":["Send branch_ref_bytes as a full ref name like refs/heads/my-branch","Use gix::refs::FullName::try_from on the client side to validate before submitting","Update the calling client/SDK to the current assignment API format"],"exampleFix":"// before\nHunkAssignmentTarget::Branch { branch_ref_bytes: BString::from(\"my-branch\") }\n// after\nHunkAssignmentTarget::Branch { branch_ref_bytes: BString::from(\"refs/heads/my-branch\") }","handlingStrategy":"validation","validationCode":"if let HunkAssignmentTarget::Branch { branch_ref_bytes } = &req.target {\n    if gix::refs::FullName::try_from(branch_ref_bytes.clone()).is_err() {\n        eprintln!(\"Invalid ref for {} — use refs/heads/<name>\", req.path_bytes.to_str_lossy());\n        continue;\n    }\n}","typeGuard":"fn valid_branch_target(t: &HunkAssignmentTarget) -> bool {\n    match t {\n        HunkAssignmentTarget::Branch { branch_ref_bytes } =>\n            gix::refs::FullName::try_from(branch_ref_bytes.clone()).is_ok(),\n        _ => true,\n    }\n}","tryCatchPattern":null,"preventionTips":["Construct branch targets via gix::refs::FullName, not raw bytes","Validate all request targets before calling assign","Keep client SDK versions in sync with the assignment API format"],"tags":["validation","git","refs"],"backgroundTag":"invalid-identifier-format","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}