languagetool-org/languagetool · error · BadRequestException

You can specify 'noopLanguages' only when also using 'langua

Error message

You can specify 'noopLanguages' only when also using 'language=auto'

What it means

The optional 'noopLanguages' parameter (languages to ignore during automatic language detection) is only meaningful together with language=auto. checkText throws BadRequestException when noopLanguages is supplied but the request does not use automatic detection, logging INVALID_REQUEST metrics.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/TextChecker.java:474

    List<String> dictWords = limits.getPremiumUid() != null ?
      TelemetryProvider.INSTANCE.createSpan(SPAN_NAME_PREFIX +"GetUserDictWords", Attributes.empty(), () -> getUserDictWords(limits, finalDictGroups)) : Collections.emptyList();

    boolean filterDictionaryMatches = "true".equals(params.getOrDefault("filterDictionaryMatches", "true"));

    Long textSessionId = computeTextSessionID(params.get("textSessionId"), remoteAddress);

    List<String> abTest = AB_TEST_SERVICE.getActiveAbTestForClient(params, config);

    boolean enableHiddenRules = "true".equals(params.get("enableHiddenRules"));
    if (limits.hasPremium()) {
      enableHiddenRules = false;
    }

    boolean autoDetectLanguage = getLanguageAutoDetect(params);
    List<String> preferredVariants = getPreferredVariants(params);
    if (params.get("noopLanguages") != null && !autoDetectLanguage) {
      ServerMetricsCollector.getInstance().logRequestError(ServerMetricsCollector.RequestErrorType.INVALID_REQUEST);
      throw new BadRequestException("You can specify 'noopLanguages' only when also using 'language=auto'");
    }
    List<String> noopLangs = params.get("noopLanguages") != null ?
            Arrays.asList(params.get("noopLanguages").split(",")) : Collections.emptyList();
    List<String> preferredLangs = params.get("preferredLanguages") != null ?
            Arrays.asList(params.get("preferredLanguages").split(",")) : Collections.emptyList();
    DetectedLanguage detLang = TelemetryProvider.INSTANCE.createSpan(SPAN_NAME_PREFIX + "DetetectLanguage", Attributes.empty(), () -> getLanguage(aText.getPlainText(), params, preferredVariants, noopLangs, preferredLangs,
      params.getOrDefault("ld", "control").equalsIgnoreCase("test")));
    Language lang = detLang.getGivenLanguage();

    List<Rule> userRules = TelemetryProvider.INSTANCE.createSpan(SPAN_NAME_PREFIX + "GetUserRules", Attributes.empty(), () -> getUserRules(limits, lang, finalDictGroups));
    String ltAgent = params.getOrDefault("useragent", "unknown");
    Pattern trustedSourcesPattern = config.getTrustedSources();
    boolean trustedSource = trustedSourcesPattern == null || (limits.hasPremium() || trustedSourcesPattern.matcher(ltAgent).matches());
    boolean optInThirdPartyAI = isOptInThirdPartyAI(limits, params, config);

    // set default value for tokenType
    UserConfig.TokenType tokenType = authHeader == null ? UserConfig.TokenType.NO_TOKEN : UserConfig.TokenType.INVALID_TOKEN;
    JwtContent jwtContent = limits.getJwtContent();

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Set language=auto in the same request when using noopLanguages
  2. Remove the noopLanguages parameter when you specify a concrete language
  3. In client code, only include noopLanguages when the auto-detect mode is active

Example fix

// before
curl -d text=... -d language=en-US -d noopLanguages=de http://server/v2/check
// after
curl -d text=... -d language=auto -d noopLanguages=de http://server/v2/check
Defensive patterns

Strategy: validation

Validate before calling

if (params.noopLanguages && params.language !== 'auto') {
  params.language = 'auto'; // or delete params.noopLanguages
}

Type guard

function canUseNoopLanguages(p) {
  return p.noopLanguages == null || p.language === 'auto';
}

Prevention

When it happens

Trigger: Sending /v2/check with parameter noopLanguages set (e.g. noopLanguages=de,en) while language is a fixed code (language=en-US) or absent — getLanguageAutoDetect(params) returns false.

Common situations: Clients that always append detection-tuning parameters regardless of the language mode; SDK wrappers that serialize all options unconditionally; copy-pasted request examples mixing auto-detect and fixed-language settings.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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