languagetool-org/languagetool · error · BadRequestException
You cannot specify disabled rules or categories using enable
Error message
You cannot specify disabled rules or categories using enabledOnly=true
What it means
When enabledOnly=true is used, the check should be restricted exclusively to explicitly enabled rules/categories. Supplying disabledRules or disabledCategories alongside enabledOnly is contradictory, so checkText throws BadRequestException and logs an INVALID_REQUEST metric.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/TextChecker.java:563
List<String> disabledRules = getDisabledRuleIds(params);
List<CategoryId> enabledCategories = getCategoryIds("enabledCategories", params);
List<CategoryId> disabledCategories = getCategoryIds("disabledCategories", params);
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 {View on GitHub (pinned to 2e990059ce)
Solutions
- Remove disabledRules/disabledCategories from the request when using enabledOnly=true
- Encode everything you want to exclude by omitting it from the enabledRules/enabledCategories lists instead of disabling it
- In client code, drop or ignore disable-lists when the enabledOnly option is set
Example fix
// before curl -d text=... -d language=en-US -d enabledOnly=true -d disabledRules=WHITESPACE_RULE http://server/v2/check // after curl -d text=... -d language=en-US -d enabledOnly=true -d enabledRules=... http://server/v2/check
Defensive patterns
Strategy: validation
Validate before calling
if (params.enabledOnly && ((params.disabledRules?.length) || (params.disabledCategories?.length))) {
delete params.disabledRules;
delete params.disabledCategories;
} Prevention
- Treat enabledOnly as exclusive with any disable-lists
- Model rule configuration as either enable-set or disable-set, never both
- Centralize request-param assembly so the conflict cannot arise from merged configs
When it happens
Trigger: POSTing to /v2/check with enabledOnly=true AND a non-empty disabledRules or disabledCategories parameter (both lists populated, e.g. disabledRules=WHITESPACE_RULE&enabledOnly=true).
Common situations: Client config layers that always send a disabled-rules list (from user preferences) while another layer turns on enabledOnly mode; merging request defaults with user options without checking for conflicts.
Related errors
- You can specify 'noopLanguages' only when also using 'langua
- You must specify enabled rules or categories when using enab
- Missing 'text' or 'data' parameter
- 'language' parameter missing
- Set only 'text' or 'data' parameter, not both
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/2a31bd1bed907c2f.
Report an issue: GitHub.