gitbutlerapp/gitbutler · error

File suffix ' ' is not allowed. Must be one of

Error message

File suffix '{}' is not allowed. Must be one of: {}

What it means

The TUI text editor helper restricts the temporary file's suffix to a fixed allow-list (.txt, .md, .patch) so editors apply appropriate syntax modes and downstream parsing is predictable. from_editor bails if the caller passes any other file_suffix string. The allow-list is explicitly open to extension in the source.

Solutions

  1. Change the caller to pass one of the allowed suffixes: .txt, .md, or .patch.
  2. If a new extension is genuinely needed, add it to the ALLOWED_SUFFIXES constant in crates/but/src/tui/get_text.rs.
  3. Fix typos — the suffix must include the leading dot and match exactly.

Example fix

// before
from_editor_no_comments(intent, None, ".commit")?;
// after
from_editor_no_comments(intent, None, ".txt")?;
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED_SUFFIXES = ['.txt', '.md', '.patch'];
function suffixAllowed(s: string): boolean {
  return ALLOWED_SUFFIXES.includes(s);
}

Type guard

function isAllowedSuffix(s: string): s is '.txt' | '.md' | '.patch' {
  return ['.txt', '.md', '.patch'].includes(s);
}

Prevention

When it happens

Trigger: Calling from_editor / from_editor_no_comments / from_editor_no_comments_as_patch with a file_suffix not in [.txt, .md, .patch] — e.g. '.log', '.json', 'txt' (missing dot), or an empty string.

Common situations: New CLI/TUI commands passing a domain-appropriate extension that was never added to ALLOWED_SUFFIXES; typos like '.patched' or 'patch'.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/ebb0969c3210a770. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/tui/get_text.rs:66

}

/// Launches the user's preferred text editor to edit some `initial_text`,
/// identified by a `filename_safe_intent` to help the user understand what's wanted of them.
/// Note that this string must be valid in filenames.
///
/// If the user has an external editor configured (via `GIT_EDITOR`, `core.editor`, or `EDITOR`),
/// that editor is used. Otherwise, the built-in TUI editor is launched.
///
/// Returns the edited text (*without known encoding*) verbatim.
pub fn from_editor(
    filename_safe_intent: &str,
    initial_text: &str,
    rest_text: Option<&str>,
    file_suffix: &str,
) -> Result<BString> {
    const ALLOWED_SUFFIXES: &[&str] = &[".txt", ".md", ".patch"]; // feel free to add more allowed suffixes
    if !ALLOWED_SUFFIXES.contains(&file_suffix) {
        bail!(
            "File suffix '{}' is not allowed. Must be one of: {}",
            file_suffix,
            ALLOWED_SUFFIXES.join(", ")
        );
    }

    match get_editor_command() {
        Some(editor_cmd) => from_external_editor(
            &editor_cmd,
            filename_safe_intent,
            initial_text,
            rest_text,
            file_suffix,
        ),
        None => from_builtin_editor(filename_safe_intent, initial_text, rest_text),
    }
}

View on GitHub (pinned to 58e5313667)