jubins opened a new pull request, #29943: URL: https://github.com/apache/flink/pull/29943
## What is the purpose of the change Fixes [FLINK-41500](https://issues.apache.org/jira/browse/FLINK-41500). `UpperLimitExceptionParameter` (the `maxExceptions` query parameter of `/jobs/:jobid/exceptions` and `/applications/:applicationid/exceptions`) accepts any integer. A negative value passes parameter resolution and reaches `Stream#limit` in `JobExceptionsHandler#createJobExceptionHistory` and `ApplicationExceptionsInfoWithHistory#fromApplicationExceptionHistory`, which throws `IllegalArgumentException: -1`. `AbstractHandler` maps that to HTTP 500 and logs `Unhandled exception.` at ERROR level, so a client typo looks like a server fault. A non-numeric value is already rejected with 400, because `convertStringToValue` throws during `HandlerRequest` resolution. `SubtaskIndexQueryParameter` already rejects negative values the same way with a `ConversionException`. This PR makes `maxExceptions` follow that pattern. `0` stays valid and returns an empty, truncated history, as it does today. ## Brief change log - `UpperLimitExceptionParameter#convertStringToValue` throws `ConversionException("maxExceptions must not be negative, was: <n>")` for values below 0. `HandlerRequest#resolveQueryParameters` turns that into a `HandlerRequestException`, which the REST layer answers with 400 Bad Request. - The parameter description and the multi-value parsing are unchanged (those are tracked separately in FLINK-20004 and FLINK-32198). ## Verifying this change This change added tests and can be verified as follows: - Added `UpperLimitExceptionParameterTest`: `0` and `5` are accepted, `-1` is rejected with `ConversionException` and the exact message, and `abc` is still rejected with `NumberFormatException`. - Added `JobExceptionsHandlerTest#testNegativeMaxExceptionsIsRejected` and `ApplicationExceptionsHandlerTest#testNegativeMaxExceptionsIsRejected`: resolving a request with `maxExceptions=-1` through `HandlerRequest.resolveParametersAndCreate` fails with `HandlerRequestException` (the 400 path) instead of reaching the handler. - All three new negative-value tests fail on `master` (`Expecting code to raise a throwable.`) and pass with the fix. `JobExceptionsHandlerTest` (15), `ApplicationExceptionsHandlerTest` (7), `UpperLimitExceptionParameterTest` (4), `JobExceptionsMessageParametersTest` (2) and `SubtaskIndexPathParameterTest` (4) pass locally on JDK 21. - No REST API snapshot or generated docs change: the snapshot only records the parameter key and requisiteness, and the description is unchanged. ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? not applicable --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Claude Opus 5.5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
