gitbutlerapp/gitbutler · warning · serde_error::Error

dependencies_error: dependencies.as_ref().err().map(|err|…

Error message

dependencies_error: dependencies.as_ref().err().map(|err| serde_error::Error::new(&**err))

What it means

An error field on the WorktreeChanges result: dependencies_error carries the failure from computing file dependencies, serialized via serde_error::Error. The dependency graph for the changes is unavailable while the rest of the payload (worktree_changes, assignments) is still returned.

Solutions

  1. Read dependencies_error to identify the failing computation and retry
  2. Use the result without dependencies (treat as null) and compute dependencies on demand
  3. Rebuild/refresh the dependency index if the error persists
  4. Check whether changed files belong to a supported project/dependency scope

Example fix

// before
const deps = wc.dependencies!;  // may be null
// after
if (wc.dependenciesError) console.warn(wc.dependenciesError);
const deps = wc.dependencies ?? null;
Defensive patterns

Strategy: fallback

Type guard

const hasDependencies = (wc) => wc.dependenciesError == null && wc.dependencies != null;

Try / catch

const wc = await api.worktreeChanges(...);
if (wc.dependenciesError) { log.warn('dependencies unavailable:', wc.dependenciesError); }
const deps = wc.dependencies ?? null;

Prevention

When it happens

Trigger: Dependency computation for the changed files fails (dependency database/index error) during the worktree-changes API call; the Err is captured and attached instead of failing the whole request.

Common situations: Missing or corrupted dependency database entries, files outside tracked projects, or an internal parser failure on a specific file type.

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


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/108a31b7a4830a77. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-api/src/diff.rs:238

        )?
    };

    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(
    ctx: &Context,
    assignments: Vec<HunkAssignmentRequest>,
) -> anyhow::Result<()> {
    let guard = ctx.shared_worktree_access();
    assign_hunk_only_with_perm(ctx, assignments, guard.read_permission())

View on GitHub (pinned to 58e5313667)