languagetool-org/languagetool · error · BadRequestException

'language' parameter missing

Error message

'language' parameter missing

What it means

handleGetConfigurationInfoRequest (/v2/configuration-info) requires a 'language' parameter to know which language's configuration options to describe. When the parameter is absent, it throws BadRequestException (HTTP 400).

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/ApiV2.java:127

  private void handleLanguagesRequest(HttpExchange httpExchange) throws IOException {
    String response = getLanguages();
    ServerTools.setCommonHeaders(httpExchange, JSON_CONTENT_TYPE, allowOriginUrl);
    httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, response.getBytes(ENCODING).length);
    httpExchange.getResponseBody().write(response.getBytes(ENCODING));
    ServerMetricsCollector.getInstance().logResponse(HttpURLConnection.HTTP_OK);
  }

  private void handleMaxTextLengthRequest(HttpExchange httpExchange, HTTPServerConfig config) throws IOException {
    String response = Integer.toString(config.getMaxTextLengthAnonymous());
    ServerTools.setCommonHeaders(httpExchange, TEXT_CONTENT_TYPE, allowOriginUrl);
    httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, response.getBytes(ENCODING).length);
    httpExchange.getResponseBody().write(response.getBytes(ENCODING));
    ServerMetricsCollector.getInstance().logResponse(HttpURLConnection.HTTP_OK);
  }

  private void handleGetConfigurationInfoRequest(HttpExchange httpExchange, Map<String, String> parameters, HTTPServerConfig config) throws IOException {
    if (parameters.get("language") == null) {
      throw new BadRequestException("'language' parameter missing");
    }
    Language lang = Languages.getLanguageForShortCode(parameters.get("language"));
    String response = getConfigurationInfo(lang, config);
    ServerTools.setCommonHeaders(httpExchange, JSON_CONTENT_TYPE, allowOriginUrl);
    httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, response.getBytes(ENCODING).length);
    httpExchange.getResponseBody().write(response.getBytes(ENCODING));
    ServerMetricsCollector.getInstance().logResponse(HttpURLConnection.HTTP_OK);
  }

  private void handleSoftwareInfoRequest(HttpExchange httpExchange) throws IOException {
    String response = getSoftwareInfo();
    ServerTools.setCommonHeaders(httpExchange, JSON_CONTENT_TYPE, allowOriginUrl);
    httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, response.getBytes(ENCODING).length);
    httpExchange.getResponseBody().write(response.getBytes(ENCODING));
    ServerMetricsCollector.getInstance().logResponse(HttpURLConnection.HTTP_OK);
  }

  private void handleCheckRequest(HttpExchange httpExchange, Map<String, String> parameters, ErrorRequestLimiter errorRequestLimiter, String remoteAddress, HTTPServerConfig config) throws Exception {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Add the language parameter, e.g. ?language=en-US
  2. Use a valid short code accepted by Languages.getLanguageForShortCode
  3. Ensure the parameter is sent in the POST body or query string as expected by the client

Example fix

// before
curl 'http://server:8081/v2/configuration-info'
// after
curl 'http://server:8081/v2/configuration-info?language=en-US'
Defensive patterns

Strategy: validation

Validate before calling

const params = new URLSearchParams({ language: 'en-US' });
if (!params.has('language')) throw new Error('language required');
fetch(`${base}/v2/configuration-info?${params}`);

Try / catch

try {
    const info = await getConfigurationInfo(lang);
} catch (e) {
    if (/language.*parameter missing/.test(e.message)) {
        console.error('Supply ?language=<shortcode>');
    } else throw e;
}

Prevention

When it happens

Trigger: GET/POST /v2/configuration-info without language=..., or sending the parameter under a misspelled name (e.g. 'lang', 'locale').

Common situations: Client libraries built against an older API shape, hand-rolled curl commands omitting the query parameter.

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/112902bc183b9eab. Report an issue: GitHub.