{"record":{"id":"f19cf6638321953e","repo":"gitbutlerapp/gitbutler","slug":"invalid-section-for-global-key-key","errorCode":null,"errorMessage":"Invalid section for global key: {key}","messagePattern":"Invalid section for global key: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/git.rs","lineNumber":113,"sourceCode":"        Ok(())\n    })?;\n    Ok(())\n}\n\n#[but_api]\n#[instrument(err(Debug))]\npub fn git_get_global_config(key: String) -> Result<Option<String>> {\n    let config = gix::config(None, &gix::open::Options::default())?;\n    Ok(get_config_string(&config, &key))\n}\n\nfn get_config_string(config: &gix::config::File, key: &str) -> Option<String> {\n    config.string(key).map(|s| s.to_string())\n}\n\nfn validate_gitbutler_global_key(key: &str) -> Result<()> {\n    if !key.starts_with(\"gitbutler.\") {\n        bail!(\"Invalid section for global key: {key}\")\n    }\n    Ok(())\n}\n","sourceCodeStart":95,"sourceCodeEnd":117,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/legacy/git.rs#L95-L117","documentation":"When setting or removing global GitButler config entries, the key must live in the 'gitbutler.' config section. validate_gitbutler_global_key rejects any key that does not start with 'gitbutler.', preventing arbitrary global git config from being written through this API.","triggerScenarios":"Calling git_set_global_config or git_remove_global_config with a key like 'user.name' or 'core.editor' (missing the 'gitbutler.' prefix).","commonSituations":"Frontend passing a plain git config key by mistake; attempting to use the GitButler API to edit general git settings; typos like 'gitbutler.x'.","solutions":["Prefix the key with 'gitbutler.' (e.g. 'gitbutler.myOption')","Use standard git tooling (git config --global) for non-GitButler keys","Check the exact key name for typos"],"exampleFix":"// before\nawait gitSetGlobalConfig(\"user.name\", name);\n// after\nawait gitSetGlobalConfig(\"gitbutler.userName\", name);","handlingStrategy":"validation","validationCode":"if (!key.startsWith('gitbutler.')) {\n  throw new Error(`Key must be in gitbutler. section: ${key}`);\n}\nawait gitSetGlobalConfig(key, value);","typeGuard":"function isGitButlerKey(key) { return key.startsWith('gitbutler.'); }","tryCatchPattern":"try {\n  await gitSetGlobalConfig(key, value);\n} catch (e) {\n  if (String(e).includes('Invalid section for global key')) {\n    await gitSetGlobalConfig(`gitbutler.${key}`, value);\n  } else throw e;\n}","preventionTips":["Always prefix app-managed global keys with 'gitbutler.'","Use `git config --global` directly for non-GitButler settings","Validate key format in the UI before calling the API"],"tags":["rust","config","validation"],"backgroundTag":"invalid-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"}