{"record":{"id":"e7928fd1c38c8f9c","repo":"gitbutlerapp/gitbutler","slug":"editing-source-config-through-a-repository-is-not-supported","errorCode":null,"errorMessage":"editing {source:?} config through a repository is not supported","messagePattern":"editing (.+?) config through a repository is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-core/src/git_config.rs","lineNumber":76,"sourceCode":"        config\n            .commit()\n            .with_context(|| format!(\"failed to commit git config at {}\", path.display()))?;\n    }\n    Ok(changed)\n}\n\n/// Edit the Git config for `source` using `repo`, resolving its path as described in [`edit_config()`].\n/// Write it back if the edited configuration differs from its original state.\npub fn edit_repo_config(\n    repo: &gix::Repository,\n    source: gix::config::Source,\n    edit: impl FnOnce(&mut gix::config::File) -> Result<()>,\n) -> Result<bool> {\n    if matches!(\n        source,\n        gix::config::Source::System | gix::config::Source::GitInstallation\n    ) {\n        bail!(\"editing {source:?} config through a repository is not supported\");\n    }\n    edit_config(Some(repo), source, edit)\n}\n\n/// Set the entry in `config` identified by the dotted `key` (like `section.value` or `section.subsection.value`) to `value`.\n/// This will create sections as needed, and remove all previous values under the same section with the same name.\npub fn set_config_value(config: &mut gix::config::File, key: &str, value: &str) -> Result<()> {\n    remove_config_value(config, key)?;\n    let key = key\n        .try_as_key()\n        .with_context(|| format!(\"invalid git config key: {key}\"))?;\n    config\n        .section_mut_or_create_new(key.section_name, key.subsection_name)?\n        .set(key.value_name, value)?;\n    Ok(())\n}\n\n/// Ensure `value` is present in `config` for the multi-valued Git entry identified by `key`.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-core/src/git_config.rs#L58-L94","documentation":"edit_repo_config() edits a git config file through a repository handle, but system-level and installation-level config sources have no repository scope. Attempting to route edits to those sources through a repo is rejected up front with this error.","triggerScenarios":"Calling any of the wrappers (add_remote_to_config, persist_to_local_config, set_target_ref_and_init_project, edit_git_config, setup_local_remote, set_exclude_decoration) with source = Source::System or Source::GitInstallation, typically because the config lookup resolved to a global/system file.","commonSituations":"A setting being modified actually lives in /etc/gitconfig or the installation prefix config; misconfigured source detection passing the wrong enum variant; tests that point config sources at system scope.","solutions":["Target Source::Local (repository) config for repo-scoped edits","Edit system/installation config directly with gix::config::File::from_paths and write it back outside the repo API","Log/inspect which source the value currently comes from before editing","Guard calls so only repo-scoped sources reach this API"],"exampleFix":"// before\nedit_repo_config(&repo, gix::config::Source::System, |f| { f.set_raw_value(\"user.name\", \"x\") })?;\n// after\nlet source = gix::config::Source::Local;\nedit_repo_config(&repo, source, |f| { f.set_raw_value(\"user.name\", \"x\") })?;","handlingStrategy":"validation","validationCode":"fn repo_scoped(source: gix::config::Source) -> bool {\n    !matches!(source, gix::config::Source::System | gix::config::Source::GitInstallation)\n}","typeGuard":null,"tryCatchPattern":"match edit_repo_config(&repo, source, edit) {\n    Err(e) if e.to_string().contains(\"not supported\") => edit_global_config_file_directly(),\n    other => other?,\n}","preventionTips":["Default edits to Source::Local for repository settings","Detect the source of a value before attempting to change it","Use direct file editing APIs for system/installation scope","Keep global vs repo config flows separate in tooling"],"tags":["git","config","scopes"],"backgroundTag":"unsupported-config-value","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"}