Jubin Soni created FLINK-41500:
----------------------------------
Summary: Reject a negative maxExceptions query parameter with 400
instead of failing with 500
Key: FLINK-41500
URL: https://issues.apache.org/jira/browse/FLINK-41500
Project: Flink
Issue Type: Bug
Components: Runtime / REST
Affects Versions: 2.3.0, 2.5.0, 2.4.0
Reporter: Jubin Soni
h2. Bug / gap
UpperLimitExceptionParameter (maxExceptions) accepts any integer. A negative
value reaches Stream#limit in JobExceptionsHandler#createJobExceptionHistory
and ApplicationExceptionsInfoWithHistory#fromApplicationExceptionHistory, which
throw IllegalArgumentException. AbstractHandler treats it as an unhandled
exception: the client gets HTTP 500 "Internal server error." with a server
stack trace, and the JobManager logs "Unhandled exception." at ERROR. A
non-numeric value is already rejected with 400 during parameter resolution, and
SubtaskIndexQueryParameter already rejects negative values with a
ConversionException.
h2. Reproduction
{code}
GET /jobs/<jobId>/exceptions?maxExceptions=abc -> 400 Bad request, could not
parse parameters
GET /jobs/<jobId>/exceptions?maxExceptions=-1 -> 500 Internal server error
(java.lang.IllegalArgumentException: -1 from Stream.limit)
GET /applications/<appId>/exceptions?maxExceptions=-1 -> same code path
(ApplicationExceptionsInfoWithHistory uses .limit(maxSize))
{code}
Expected:
{code}
400 Bad request, could not parse parameters: Cannot resolve query parameter
(maxExceptions) from value "-1".
{code}
h2. Why it matters
A client mistake is reported as a server failure and logged at ERROR on the
JobManager, which misleads both REST client authors and operators.
h2. Related work
FLINK-39711 / FLINK-39730 exposed and honoured maxExceptions on both handlers.
FLINK-32198 (open) is about rejecting multiple values and is not changed here.
FLINK-20004 (open) is about the parameter description. FLINK-41284 (open) is a
different 500-instead-of-4xx case on the application endpoints. Searched JIRA
for maxExceptions / UpperLimitExceptionParameter / ApplicationExceptionsHandler
and GitHub PRs for the same on 2026-11-14.
h2. Proposed fix
Throw a ConversionException from
UpperLimitExceptionParameter#convertStringToValue for values below 0, as
SubtaskIndexQueryParameter does, so HandlerRequest resolution turns it into a
400 for both endpoints. Add UpperLimitExceptionParameterTest, and a case in
JobExceptionsHandlerTest that resolving maxExceptions=-1 fails with
HandlerRequestException.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)