languagetool-org/languagetool · error · BadRequestException
You must specify enabled rules or categories when using enab
Error message
You must specify enabled rules or categories when using enabledOnly=true
What it means
enabledOnly=true restricts the check to explicitly enabled rules, so at least one enabled rule or category must be given. checkText throws BadRequestException when enabledOnly=true is set but both enabledRules and enabledCategories are empty, logging INVALID_REQUEST metrics.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/TextChecker.java:567
if (shouldRunRestrictedRulesTest(params, agent, lang, abTest)) {
log.info("Running test with restricted rules for user: {}, language: {}, client: {}",
params.getOrDefault("username", ""), lang.getShortCodeWithCountryAndVariant(), agent);
useEnabledOnly = true;
enabledRules = onlyTestRules;
// need to clear these settings, leads to conflict with useEnabledOnly otherwise
disabledRules = Collections.emptyList();
disabledCategories = Collections.emptyList();
}
if ((disabledRules.size() > 0 || disabledCategories.size() > 0) && useEnabledOnly) {
ServerMetricsCollector.getInstance().logRequestError(ServerMetricsCollector.RequestErrorType.INVALID_REQUEST);
throw new BadRequestException("You cannot specify disabled rules or categories using enabledOnly=true");
}
if (enabledRules.isEmpty() && enabledCategories.isEmpty() && useEnabledOnly) {
ServerMetricsCollector.getInstance().logRequestError(ServerMetricsCollector.RequestErrorType.INVALID_REQUEST);
throw new BadRequestException("You must specify enabled rules or categories when using enabledOnly=true");
}
boolean enableTempOffRules = "true".equals(params.get("enableTempOffRules"));
boolean useQuerySettings = enabledRules.size() > 0 || disabledRules.size() > 0 ||
enabledCategories.size() > 0 || disabledCategories.size() > 0 || enableTempOffRules;
boolean allowIncompleteResults = "true".equals(params.get("allowIncompleteResults"));
JLanguageTool.Mode mode = ServerTools.getMode(params);
JLanguageTool.Level level = ServerTools.getLevel(params);
String[] toneTagNames = params.get("toneTags") != null ? params.get("toneTags").split(",") : null;
Set<ToneTag> toneTags = new HashSet<>(ToneTag.values().length);
if (toneTagNames != null) {
if (toneTagNames.length == 1 && toneTagNames[0].isEmpty()) { //&toneTags=
toneTags.add(ToneTag.ALL_WITHOUT_GOAL_SPECIFIC);
} else {
for (String toneTagName : toneTagNames) {
if (toneTagNames.length > 1 && (toneTagName.equals("NO_TONE_RULE") || toneTagName.equals("ALL_TONE_RULES"))) { //&toneTags=ALL_TONE_RULES or //&toneTags=NO_TONE_RULE
log.warn("NO_TONE_RULE and ALL_TONE_RULES will be ignored if more than one toneTag is in params.");
continue;View on GitHub (pinned to 2e990059ce)
Solutions
- Provide at least one rule id via enabledRules or one category via enabledCategories together with enabledOnly=true
- Disable enabledOnly if you intend a full check with default rules
- In client code, only send enabledOnly=true when the enabled-rule list is non-empty
Example fix
// before curl -d text=... -d language=en-US -d enabledOnly=true http://server/v2/check // after curl -d text=... -d language=en-US -d enabledOnly=true -d enabledRules=MORFOLOGIK_RULE_EN_US http://server/v2/check
Defensive patterns
Strategy: validation
Validate before calling
if (params.enabledOnly && !(params.enabledRules?.length) && !(params.enabledCategories?.length)) {
throw new Error('enabledOnly=true requires enabledRules or enabledCategories');
} Type guard
function enabledOnlyIsValid(p) {
return !p.enabledOnly || (Array.isArray(p.enabledRules) && p.enabledRules.length > 0) || (Array.isArray(p.enabledCategories) && p.enabledCategories.length > 0);
} Prevention
- Only flip enabledOnly on when at least one rule/category is selected in the UI/config
- Assert the enabled list is non-empty in client tests
- Fall back to a full check (drop enabledOnly) when the selection is empty
When it happens
Trigger: Sending /v2/check with enabledOnly=true and neither enabledRules nor enabledCategories parameters — the enable lists are empty so the request would match nothing.
Common situations: A UI toggle 'only check selected rules' switched on without any rules actually selected; programmatic clients that forward enabledOnly from config but compute enabled rule lists lazily/empty.
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
- You can specify 'noopLanguages' only when also using 'langua
- You specified altLanguage '{langCode}', but for this languag
- You cannot specify disabled rules or categories using enable
- Missing 'text' or 'data' parameter
- 'language' parameter missing
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/72383b3c57f701d4.
Report an issue: GitHub.