gitbutlerapp/gitbutler · warning · serde_error::Error
assignments_error: assignments_error.map(|err|…
Error message
assignments_error: assignments_error.map(|err| serde_error::Error::new(&*err))
What it means
Not a thrown error but an error field on the WorktreeChanges result: assignments_error carries the failure that occurred while computing workspace assignments, serialized via serde_error::Error for the client. The main worktree_changes payload is still returned; this signals the assignments portion is missing.
Solutions
- Inspect the serialized assignments_error message for the root cause
- Re-open/refresh the workspace state and retry the worktree-changes call
- Treat the result as partial: use worktree_changes but regenerate assignments separately
- If persistent, reset/rebuild workspace metadata via the workspace APIs
Example fix
// before const wc = await api.worktreeChanges(...); use(wc.assignments); // may be null // after const wc = await api.worktreeChanges(...); if (wc.assignmentsError) console.warn(wc.assignmentsError); use(wc.assignments ?? []);
Defensive patterns
Strategy: fallback
Type guard
const hasAssignments = (wc) => wc.assignmentsError == null && Array.isArray(wc.assignments);
Try / catch
const wc = await api.worktreeChanges(...);
if (wc.assignmentsError) { log.warn('assignments unavailable:', wc.assignmentsError); }
const assignments = wc.assignments ?? []; Prevention
- Never assume assignments is non-null on WorktreeChanges
- Always surface assignments_error to the UI as a degraded state
- Retry the call after workspace metadata changes
When it happens
Trigger: The workspace assignment computation inside the worktree-changes API fails (workspace/database lookup error) while diffing succeeds — the Result::Err is captured and attached rather than propagated.
Common situations: Corrupt or stale workspace data, a failed workspace snapshot read, or concurrent modification of the workspace during the call.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- dependencies_error: dependencies.as_ref().err().map(|err|…
- a committed transaction always materializes a workspace
- Ad-hoc (single-branch) branch moves are not supported…
- assignments_error: assignments_error.clone()…
- assignments_error.map(|err| serde_error::Error::new(&*err))
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/694dbea045e4a9ab.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/diff.rs:233
trans.hunk_assignments_mut()?,
&repo,
&ws,
Some(changes.changes.clone()),
context_lines,
)?
};
trans.commit()?;
let mut worktree_changes: but_core::ui::WorktreeChanges = changes.into();
worktree_changes.modification_times =
but_core::diff::ui::modification_times(&repo, &worktree_changes);
drop((repo, ws, db));
Ok(WorktreeChanges {
worktree_changes,
assignments,
assignments_error: assignments_error.map(|err| serde_error::Error::new(&*err)),
dependencies: dependencies.as_ref().ok().cloned(),
dependencies_error: dependencies
.as_ref()
.err()
.map(|err| serde_error::Error::new(&**err)),
})
}
/// Persists `assignments` for the current workspace without creating an oplog
/// entry.
///
/// This acquires shared worktree access from `ctx` before writing
/// assignments.
///
/// See [`assign_hunk_only_with_perm()`] for details.
#[but_api]
#[instrument(skip_all, err(Debug))]
pub fn assign_hunk_only(View on GitHub (pinned to 58e5313667)