gitbutlerapp/gitbutler · error
is required
Error message
{field} is required What it means
Raised by the required helper when a mandatory configuration value is missing or blank after trimming. Any of validate, validate_active, validate_url, or validate_ollama_endpoint can surface it, with {field} naming the offending config key.
Solutions
- Set the named config field to a non-empty value
- Run the provider setup flow (e.g. `but llm config`) to populate required keys
- Check you are reading/writing the same config scope (global vs repo-local)
Example fix
// before: provider applied without key
apply_openai_configuration(None, ...)
// after: supply required field
apply_openai_configuration(Some("sk-..."), ...) Defensive patterns
Strategy: validation
Validate before calling
// TS
function requireField(v: string | undefined, field: string): string {
if (!v || !v.trim()) throw new Error(`${field} is required`);
return v;
} Type guard
const hasValue = (v: string | null | undefined): v is string => typeof v === 'string' && v.trim().length > 0;
Prevention
- Run provider setup before first use
- Check the correct config scope (global vs repo)
- Fail fast at startup if required keys are absent
When it happens
Trigger: Running LLM configuration validation (validate/validate_active) or applying provider configuration while a required field such as an API key, model, or endpoint is unset or empty.
Common situations: Fresh checkout without provider setup, config section removed by hand, environment where the config file was never initialized.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- is required when provided
- must be an HTTP or HTTPS URL
- Invalid section for global key
- Invalid value ' '. Use true/false or 1/0.
- Ollama endpoint must use host:port format
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/663e88e9d88bbaad.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-llm/src/config.rs:400
fn nonempty(value: Option<&str>) -> Option<&str> {
value.map(str::trim).filter(|value| !value.is_empty())
}
fn validate_optional(value: Option<&str>, field: &str) -> Result<()> {
if value.is_some() && nonempty(value).is_none() {
bail!("{field} is required when provided")
}
Ok(())
}
fn config_value(config: &gix::config::File, key: &str) -> Option<String> {
config.string(key).map(|value| value.to_string())
}
fn required<'a>(value: &'a str, field: &str) -> Result<&'a str> {
let value = value.trim();
if value.is_empty() {
bail!("{field} is required")
}
Ok(value)
}
fn validate_url(value: &str, field: &str) -> Result<()> {
let value = required(value, field)?;
let url = url::Url::parse(value).with_context(|| format!("{field} must be a valid URL"))?;
if !matches!(url.scheme(), "http" | "https") || url.host_str().is_none() {
bail!("{field} must be an HTTP or HTTPS URL")
}
Ok(())
}
fn validate_ollama_endpoint(value: &str) -> Result<()> {
let value = required(value, "Ollama endpoint")?;
if value.contains("://") {
bail!("Ollama endpoint must use host:port format")
}View on GitHub (pinned to 58e5313667)