languagetool-org/languagetool · error · BadRequestException

Missing 'language' parameter, e.g. 'language=en-US' for Amer

Error message

Missing 'language' parameter, e.g. 'language=en-US' for American English or 'language=fr' for French

What it means

V2 of the LanguageTool HTTP API requires the 'language' parameter; it is missing or empty. The message also shows example values ('en-US', 'fr'). V2TextChecker.checkParams() calls super and then validates language first, before any other parameter checks.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/V2TextChecker.java:98

    return enabledRules;
  }

  @NotNull
  @Override
  protected List<String> getDisabledRuleIds(Map<String, String> parameters) {
    return getCommaSeparatedStrings("disabledRules", parameters);
  }

  @Override
  protected boolean getLanguageAutoDetect(Map<String, String> parameters) {
    return "auto".equals(parameters.get("language"));
  }

  @Override
  protected void checkParams(Map<String, String> parameters) {
    super.checkParams(parameters);
    if (StringTools.isEmpty(parameters.get("language"))) {
      throw new BadRequestException("Missing 'language' parameter, e.g. 'language=en-US' for American English or 'language=fr' for French");
    }
    if (parameters.get("enabled") != null) {
      throw new BadRequestException("You specified 'enabled' but the parameter is now called 'enabledRules' in v2 of the API");
    }
    if (parameters.get("disabled") != null) {
      throw new BadRequestException("You specified 'disabled' but the parameter is now called 'disabledRules' in v2 of the API");
    }
    if (parameters.get("preferredvariants") != null) {
      throw new BadRequestException("You specified 'preferredvariants' but the parameter is now called 'preferredVariants' (uppercase 'V') in v2 of the API");
    }
    if (parameters.get("autodetect") != null) {
      throw new BadRequestException("You specified 'autodetect' but automatic language detection is now activated with 'language=auto' in v2 of the API");
    }
  }
  
  @Override
  @NotNull
  protected DetectedLanguage getLanguage(String text, Map<String, String> parameters, List<String> preferredVariants,

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Add language=en-US (or the desired code) to the request
  2. Use language=auto for automatic language detection
  3. Fetch valid codes from /v2/languages
  4. Ensure empty-string values are not stripped or replaced by your HTTP client

Example fix

// before
params.put("text", text);
// after
params.put("text", text);
params.put("language", "en-US");
Defensive patterns

Strategy: validation

Validate before calling

if (!params.language) throw new Error("'language' is required for /v2/check, e.g. language=en-US");

Type guard

const hasLanguage = (p) => typeof p.language === 'string' && p.language.length > 0;

Try / catch

try { await check(params); } catch (e) { if (/Missing 'language' parameter/.test(e.message)) { params.language = 'auto'; return check(params); } throw e; }

Prevention

When it happens

Trigger: POST/GET to /v2/check without a language parameter, or with language= (empty); SDK calls that omit language when not using auto-detection explicitly.

Common situations: Migrating clients from v1 where language was optional with autodetect; copied example code that dropped the parameter; form handlers dropping empty fields from the request body.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/8bcba828b48c54de. Report an issue: GitHub.