{"record":{"id":"10fecf8effeca92d","repo":"gitbutlerapp/gitbutler","slug":"worktree-manipulation-is-not-enabled-featureflags","errorCode":null,"errorMessage":"worktree manipulation is not enabled (featureFlags.worktreeManipulation)","messagePattern":"worktree manipulation is not enabled \\(featureFlags\\.worktreeManipulation\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/worktrees.rs","lineNumber":75,"sourceCode":"/// updated first and otherwise by name.\n#[derive(Debug, Clone, Serialize)]\n#[cfg_attr(feature = \"export-schema\", derive(schemars::JsonSchema))]\n#[serde(rename_all = \"camelCase\")]\npub struct WorktreeListing {\n    /// Non-archived worktrees.\n    pub active: Vec<ListedWorktree>,\n    /// Archived worktrees, hidden from the workspace but still on disk.\n    pub archived: Vec<ListedWorktree>,\n}\n#[cfg(feature = \"export-schema\")]\nbut_schemars::register_sdk_type!(ListedWorktree);\n#[cfg(feature = \"export-schema\")]\nbut_schemars::register_sdk_type!(WorktreeListing);\n\n/// Fail unless the user opted into worktree manipulation.\npub fn ensure_worktree_manipulation_enabled(ctx: &but_ctx::Context) -> Result<()> {\n    if !ctx.settings.feature_flags.worktree_manipulation {\n        bail!(\"worktree manipulation is not enabled (featureFlags.worktreeManipulation)\");\n    }\n    Ok(())\n}\n\n/// Look up the *active* linked worktree named `name`.\n///\n/// Every command here operates on active worktrees only - an archived one is\n/// hidden from the graph, so operations against it could not be materialized.\n///\n/// Must not be called while a database handle is borrowed, see\n/// [`but_ctx::Context::worktrees_with_state()`].\nfn active_worktree(ctx: &but_ctx::Context, name: &str) -> Result<WorktreeEntry> {\n    let worktree = ctx\n        .worktrees_with_state()?\n        .into_iter()\n        .find(|worktree| worktree.name == name.as_bytes())\n        .with_context(|| format!(\"Worktree {name} does not exist\"))?;\n    if worktree.archived {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/worktrees.rs#L57-L93","documentation":"`ensure_worktree_manipulation_enabled` guards all worktree-mutating/listing APIs behind the experimental `featureFlags.worktreeManipulation` setting. If the flag is off in `ctx.settings`, any guarded call (open changes source, list worktrees, archive/remove a worktree) fails immediately.","triggerScenarios":"Calling `worktrees_list`, `worktree_set_archived(_with_perm)`, `worktree_remove`, or `open_changes_source` while `ctx.settings.feature_flags.worktree_manipulation` is `false`.","commonSituations":"A user on a default/older configuration invokes new worktree features; an SDK consumer never set the opt-in flag; a script automates worktrees on an installation that has not enabled the experiment.","solutions":["Enable the flag in settings: set `featureFlags.worktreeManipulation` to `true` in the GitButler config and retry","Upgrade GitButler to a version where the feature is enabled by default if available","Avoid the guarded APIs and use plain `git worktree` commands if you cannot change settings"],"exampleFix":"// before\nawait api.worktreesList(ctx); // fails: flag off\n// after\nctx.settings.featureFlags.worktreeManipulation = true; // or set in config\nawait api.worktreesList(ctx);","handlingStrategy":"try-catch","validationCode":"if (!ctx.settings.featureFlags.worktreeManipulation) {\n  throw new Error('enable featureFlags.worktreeManipulation to use worktree APIs');\n}","typeGuard":"const worktreesEnabled = (ctx: Context): boolean =>\n  ctx.settings?.featureFlags?.worktreeManipulation === true;","tryCatchPattern":"try {\n  await api.worktreesList(ctx);\n} catch (e) {\n  if (e.message.includes('worktree manipulation is not enabled')) showOptInDialog();\n}","preventionTips":["Check featureFlags.worktreeManipulation before any worktree API call","Enable the flag in installation config for automation users","Hide worktree UI features when the flag is off"],"tags":["feature-flag","worktree","configuration"],"backgroundTag":"feature-not-enabled","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"}