{"record":{"id":"fced72c22b1884fd","repo":"gitbutlerapp/gitbutler","slug":"github-stacks-configuration-requires-a-repository","errorCode":null,"errorMessage":"GitHub stacks configuration requires a repository","messagePattern":"GitHub stacks configuration requires a repository","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/config.rs","lineNumber":622,"sourceCode":"            }\n        }\n    }\n\n    Ok(())\n}\n\n/// Handle forge config subcommand (doesn't require repo context)\npub(crate) async fn forge_config(\n    out: &mut OutputChannel,\n    cmd: Option<ForgeSubcommand>,\n) -> Result<()> {\n    match cmd {\n        Some(ForgeSubcommand::Auth) => forge_auth(out).await,\n        Some(ForgeSubcommand::ListUsers) => forge_show_overview(out).await,\n        Some(ForgeSubcommand::Forget { username }) => forge_forget(username, out).await,\n        #[cfg(feature = \"legacy\")]\n        Some(ForgeSubcommand::GithubStacks { .. }) => {\n            anyhow::bail!(\"GitHub stacks configuration requires a repository\")\n        }\n        None => forge_show_overview(out).await,\n    }\n}\n\n#[cfg(feature = \"legacy\")]\npub(crate) fn github_stacks_config(\n    ctx: &mut Context,\n    out: &mut OutputChannel,\n    status: Option<GitHubStacksStatus>,\n) -> Result<()> {\n    let configured = {\n        let repo = ctx.repo.get()?;\n        match status {\n            Some(status) => {\n                let mode = match status {\n                    GitHubStacksStatus::Auto => GitHubStackingMode::Auto,\n                    GitHubStacksStatus::Enable => GitHubStackingMode::Native,","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/config.rs#L604-L640","documentation":"The `but config forge` dispatcher only handles Auth, ListUsers, Forget, and overview subcommands without a repository. The legacy `github-stacks` subcommand is repository-scoped; when forge_config is reached without a project context (the `exec` caller passes None), it is intentionally rejected as unsupported rather than misbehaving.","triggerScenarios":"Invoking `but config forge github-stacks ...` (legacy feature) in a context where no repository is open — e.g. outside a git repo or via a code path that passes no project handle — hits the bail in the ForgeSubcommand::GithubStacks match arm.","commonSituations":"Users on legacy builds running `but config forge github-stacks` outside a repository; scripts calling forge configuration before opening a project; environments where the legacy feature is compiled in but no repo context exists.","solutions":["Run the command from inside a git repository so a project context is available","Use a non-repository forge subcommand such as `but config forge auth` or `but config forge list-users` instead","Update the CLI: the legacy github-stacks subcommand is feature-gated and may be removed in favor of newer forge commands"],"exampleFix":"// before\nbut config forge github-stacks   # run from ~/\n// after\ncd /path/to/repo && but config forge github-stacks","handlingStrategy":"validation","validationCode":"if (args.some(a => a === 'github-stacks')) {\n  assert(isInsideGitRepo(process.cwd()), 'github-stacks requires a repository context');\n}","typeGuard":"const isRepoScopedForgeCmd = (sub) => ['github-stacks'].includes(sub);","tryCatchPattern":"try {\n  await exec('but config forge github-stacks ...');\n} catch (e) {\n  if (e.message.includes('requires a repository')) {\n    console.error('cd into a git repository first');\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Check the subcommand's repo requirements before scripting legacy forge commands","Prefer `forge auth`/`list-users` for non-repo contexts","Avoid relying on feature-gated legacy subcommands in automation"],"tags":["cli","git","legacy"],"backgroundTag":"missing-required-config","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"}