{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/git.rs","lineNumber":115,"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 = open_global_config_for_reading()?;\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":97,"sourceCodeEnd":119,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-api/src/legacy/git.rs#L97-L119","documentation":"git_set_global_config and git_remove_global_config validate their key through validate_gitbutler_global_key (crates/but-api/src/legacy/git.rs:113-118): only keys starting with 'gitbutler.' are accepted, so the app cannot clobber arbitrary global git config. git_get_global_config does not enforce this and reads any key.","triggerScenarios":"Calling gitSetGlobalConfig('user.name', ...) or gitRemoveGlobalConfig('core.editor') with any non-'gitbutler.' key; passing an unprefixed app setting such as 'aiReview' instead of 'gitbutler.aiReview'.","commonSituations":"Integrations assuming this wraps `git config --global`; settings code that stores the config key without its namespace prefix; typos like 'gitbutler' (missing dot).","solutions":["Prefix the key with 'gitbutler.' (e.g. 'gitbutler.aiReview')","For real git config such as user.name or core.editor, write it with git itself (`git config --global ...`) outside this API","Reads accept any key: use gitGetGlobalConfig to verify the value after writing"],"exampleFix":"// before: non-namespaced key\nawait client.gitSetGlobalConfig('aiReview', 'true');\n// error: Invalid section for global key: aiReview\n\n// after: gitbutler namespace\nawait client.gitSetGlobalConfig('gitbutler.aiReview', 'true');\nawait client.gitGetGlobalConfig('gitbutler.aiReview'); // 'true'","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isGitButlerConfigKey(key: string): boolean {\n  return key.startsWith('gitbutler.');\n}\n\n// usage\nif (!isGitButlerConfigKey(key)) {\n  throw new RangeError(`key must be namespaced under 'gitbutler.': ${key}`);\n}\nawait client.gitSetGlobalConfig(key, value);","tryCatchPattern":"try {\n  await client.gitSetGlobalConfig(key, value);\n} catch (e) {\n  if (String(e).startsWith('Invalid section for global key')) {\n    await client.gitSetGlobalConfig(`gitbutler.${key}`, value); // retry namespaced\n  } else throw e;\n}","preventionTips":["Namespace all app settings written through this API under 'gitbutler.'","Use plain `git config --global` for anything outside the app's namespace","Remember reads (gitGetGlobalConfig) accept any key; only writes/removes validate"],"tags":["git","config","validation","namespacing","rust"],"backgroundTag":"config-key-validation","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}