Skip to content

Exceeding index.analyze.max_token_count should return in a client error instead of a internal server error? #116323

@martijnvg

Description

@martijnvg

I noticed the following analyze request error being returned with status code 500. I think a 400 status code is more appropriate?

path: /_analyze, params: {xxx, xxx}, status: 500
org.elasticsearch.transport.RemoteTransportException: [...][...][indices:admin/analyze[s]]
Caused by: java.lang.IllegalStateException: The number of tokens produced by calling _analyze has exceeded the allowed maximum of [10000]. This limit can be set by changing the [index.analyze.max_token_count] index level setting.
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction$TokenCounter.increment(TransportAnalyzeAction.java:458)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.simpleAnalyze(TransportAnalyzeAction.java:275)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.analyze(TransportAnalyzeAction.java:242)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.analyze(TransportAnalyzeAction.java:148)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:127)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:64)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.support.single.shard.TransportSingleShardAction.lambda$asyncShardOperation$0(TransportSingleShardAction.java:113)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionRunnable$3.accept(ActionRunnable.java:79)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionRunnable$3.accept(ActionRunnable.java:76)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionRunnable$4.doRun(ActionRunnable.java:101)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:1023)
	at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:27)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions