{"record":{"id":"4fe7aa017457ac7e","repo":"gitbutlerapp/gitbutler","slug":"assignments-error-map-err-serde-error-error-new-err","errorCode":null,"errorMessage":"assignments_error.map(|err| serde_error::Error::new(&*err))","messagePattern":"assignments_error\\.map\\(\\|err\\| serde_error::Error::new\\(&\\*err\\)\\)","errorType":"error_code","errorClass":"serde_error::Error","httpStatus":null,"severity":"info","filePath":"crates/gitbutler-watcher/src/handler.rs","lineNumber":264,"sourceCode":"fn assignments_and_errors(\n    db: HunkAssignmentsHandleMut,\n    repo: &gix::Repository,\n    workspace: &but_graph::Workspace,\n    tree_changes: Vec<TreeChange>,\n    context_lines: u32,\n) -> Result<(Vec<HunkAssignment>, Option<serde_error::Error>)> {\n    let (assignments, assignments_error) = {\n        but_hunk_assignment::assignments_with_fallback(\n            db,\n            repo,\n            workspace,\n            Some(tree_changes),\n            context_lines,\n        )?\n    };\n    Ok((\n        assignments,\n        assignments_error.map(|err| serde_error::Error::new(&*err)),\n    ))\n}\n","sourceCodeStart":246,"sourceCodeEnd":267,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-watcher/src/handler.rs#L246-L267","documentation":"In `assignments_and_errors`, the anyhow assignment error is mapped into a serializable `serde_error::Error` before being returned to `emit_worktree_changes`, so the UI receives the assignment failure message alongside the (possibly empty) assignment results. The error is intentionally non-fatal: results and error travel together.","triggerScenarios":"Calling the worktree-changes pipeline when `but_hunk_assignment` fails to compute assignments (e.g. reference resolution failure, database error, conflicting assignment rules), so `assignments_error` is `Some` and gets converted for the event payload.","commonSituations":"Workspace database locked or mid-migration while the watcher polls; assignment rules referencing deleted branches; concurrent CLI and app operations on the same project corrupting intermediate state.","solutions":["Inspect the `assignments_error` string on the emitted event for the root cause.","Retry by triggering a status refresh once the conflicting operation completes.","Remove stale assignment rules pointing at deleted branches.","If the workspace database is locked, close other GitButler clients on the same project."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let (assignments, err) = assignments_and_errors(...)?;\nif let Some(e) = err {\n    tracing::warn!(error = %e, \"assignment failed; falling back to unassigned view\");\n}","preventionTips":["Avoid concurrent clients on the same project while the watcher runs.","Clean up assignment rules that reference deleted branches.","Trigger a manual status refresh after failed ticks."],"tags":["watcher","assignments","serialization"],"backgroundTag":"hunk-assignment-failed","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"}