SubtitleEdit/subtitleedit · error · InvalidOperationException

Translate engine ' ' is not supported. Use one of: .

Error message

Translate engine '{options.TranslateEngine}' is not supported. Use one of: {string.Join(", ", SupportedEngines)}.

What it means

InvalidOperationException from the engine-name switch in AutoTranslateRunner: the value of options.TranslateEngine did not match any case (the supported set like 'libretranslate', 'nllb-serve', 'nllb-api', 'llamacpp', etc.). The message lists SupportedEngines so the user sees the accepted values.

Solutions

  1. Print SupportedEngines (it is in the error message) and use one of those exact strings.
  2. If you need a deprecated engine, check the runner's SupportedEngines constant for the canonical name.
  3. Normalize input: trim and lowercase the engine name before the switch.

Example fix

// before
default:
    throw new InvalidOperationException($"Translate engine '{options.TranslateEngine}' is not supported. Use one of: {string.Join(", ", SupportedEngines)}.");

// after — case-insensitive dispatch so 'LLAMACPP' matches
var key = (options.TranslateEngine ?? string.Empty).Trim().ToLowerInvariant();
switch (key) { /* ... */ default: throw new InvalidOperationException(...); }
Defensive patterns

Strategy: validation

Validate before calling

if (!SupportedEngines.Contains((options.TranslateEngine ?? "").Trim(), StringComparer.OrdinalIgnoreCase))
    throw new InvalidOperationException($"Unsupported engine. Valid: {string.Join(", ", SupportedEngines)}");

Type guard

static bool IsSupportedEngine(string? name) => name != null && SupportedEngines.Contains(name.Trim(), StringComparer.OrdinalIgnoreCase);

Try / catch

null

Prevention

When it happens

Trigger: Invoking the runner with a TranslateEngine string not present in SupportedEngines — typo, wrong casing, deprecated name, or a custom value the switch does not know.

Common situations: CLI flag --translate-engine misspelled ('llama' instead of 'llamacpp'); pipeline upgraded and an old engine name was removed; case sensitivity ('NLLB' vs 'nllb-api').

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/67f8c433bbd15c43. Report an issue: GitHub.

Appendix: source

Thrown at src/seconv/Core/AutoTranslateRunner.cs:113

                    tools.AutoTranslateLibreUrl = url;
                }
                break;
            case "nllb-serve":
                translator = new NoLanguageLeftBehindServe();
                if (!string.IsNullOrEmpty(url))
                {
                    tools.AutoTranslateNllbServeUrl = url;
                }
                break;
            case "nllb-api":
                translator = new NoLanguageLeftBehindApi();
                if (!string.IsNullOrEmpty(url))
                {
                    tools.AutoTranslateNllbApiUrl = url;
                }
                break;
            default:
                throw new InvalidOperationException(
                    $"Translate engine '{options.TranslateEngine}' is not supported. Use one of: {string.Join(", ", SupportedEngines)}.");
        }

        return new AutoTranslateRunner(options, translator, llamaCppModel);
    }

    /// <summary>
    /// Translates all paragraphs in place. Reuses the already-running llama-server across
    /// files in the same run (the server manager is a no-op when the model matches).
    /// </summary>
    public async Task TranslateAsync(Subtitle subtitle, CancellationToken cancellationToken)
    {
        if (_llamaCppModel != null && !LlamaCppServerManager.IsServerRunning)
        {
            if (!_options.Quiet)
            {
                Console.WriteLine($"  Starting llama-server with model {Path.GetFileName(_llamaCppModel.FileName)} (stops at exit)...");
            }

View on GitHub (pinned to 17a9f07487)