{"record":{"id":"108a31b7a4830a77","repo":"gitbutlerapp/gitbutler","slug":"dependencies-error-dependencies-as-ref-err-map-err-serde","errorCode":null,"errorMessage":"dependencies_error: dependencies.as_ref().err().map(|err| serde_error::Error::new(&**err))","messagePattern":"dependencies_error: dependencies\\.as_ref\\(\\)\\.err\\(\\)\\.map\\(\\|err\\| serde_error::Error::new\\(&\\*\\*err\\)\\)","errorType":"error_code","errorClass":"serde_error::Error","httpStatus":null,"severity":"warning","filePath":"crates/but-api/src/diff.rs","lineNumber":238,"sourceCode":"        )?\n    };\n\n    trans.commit()?;\n\n    let mut worktree_changes: but_core::ui::WorktreeChanges = changes.into();\n    worktree_changes.modification_times =\n        but_core::diff::ui::modification_times(&repo, &worktree_changes);\n    drop((repo, ws, db));\n\n    Ok(WorktreeChanges {\n        worktree_changes,\n        assignments,\n        assignments_error: assignments_error.map(|err| serde_error::Error::new(&*err)),\n        dependencies: dependencies.as_ref().ok().cloned(),\n        dependencies_error: dependencies\n            .as_ref()\n            .err()\n            .map(|err| serde_error::Error::new(&**err)),\n    })\n}\n\n/// Persists `assignments` for the current workspace without creating an oplog\n/// entry.\n///\n/// This acquires shared worktree access from `ctx` before writing\n/// assignments.\n///\n/// See [`assign_hunk_only_with_perm()`] for details.\n#[but_api]\n#[instrument(skip_all, err(Debug))]\npub fn assign_hunk_only(\n    ctx: &Context,\n    assignments: Vec<HunkAssignmentRequest>,\n) -> anyhow::Result<()> {\n    let guard = ctx.shared_worktree_access();\n    assign_hunk_only_with_perm(ctx, assignments, guard.read_permission())","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/diff.rs#L220-L256","documentation":"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.","triggerScenarios":"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.","commonSituations":"Missing or corrupted dependency database entries, files outside tracked projects, or an internal parser failure on a specific file type.","solutions":["Read dependencies_error to identify the failing computation and retry","Use the result without dependencies (treat as null) and compute dependencies on demand","Rebuild/refresh the dependency index if the error persists","Check whether changed files belong to a supported project/dependency scope"],"exampleFix":"// before\nconst deps = wc.dependencies!;  // may be null\n// after\nif (wc.dependenciesError) console.warn(wc.dependenciesError);\nconst deps = wc.dependencies ?? null;","handlingStrategy":"fallback","validationCode":null,"typeGuard":"const hasDependencies = (wc) => wc.dependenciesError == null && wc.dependencies != null;","tryCatchPattern":"const wc = await api.worktreeChanges(...);\nif (wc.dependenciesError) { log.warn('dependencies unavailable:', wc.dependenciesError); }\nconst deps = wc.dependencies ?? null;","preventionTips":["Treat dependencies as optional in all consumers","Log dependencies_error for diagnosis instead of crashing","Refresh the dependency index if errors recur"],"tags":["dependencies","partial-failure","workspace"],"backgroundTag":"internal-invariant-violation","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"}