Skip to content

[FLINK-39730][runtime] Honor maxExceptions on ApplicationExceptionsHandler#28226

Open
jubins wants to merge 3 commits into
apache:masterfrom
jubins:j-flink-39730-fix-application-exceptions-handler-params
Open

[FLINK-39730][runtime] Honor maxExceptions on ApplicationExceptionsHandler#28226
jubins wants to merge 3 commits into
apache:masterfrom
jubins:j-flink-39730-fix-application-exceptions-handler-params

Conversation

@jubins
Copy link
Copy Markdown

@jubins jubins commented May 22, 2026

What is the purpose of the change

Fixes FLINK-39730ApplicationExceptionsHandler does not read the maxExceptions query parameter from the request, and ApplicationExceptionsHeaders is typed on ApplicationMessageParameters (the parent class) rather than ApplicationExceptionsMessageParameters, leaving the latter as orphaned scaffolding from FLINK-38977. As a result, typed Java REST clients setting maxExceptions on the application endpoint had the parameter silently discarded by the server, and downstream clients (e.g. flink-kubernetes-operator) had no way to bound the response size for long-running applications with large exception histories.

This is the follow-up to FLINK-39711 (PR #28202), which exposed the parameter to the typed client API for the job endpoint. Job-side parity already works end-to-end via JobExceptionsHandler; this PR brings the application endpoint to the same behavior.

Brief change log

  • Switched ApplicationExceptionsHeaders and ApplicationExceptionsHandler to be typed on ApplicationExceptionsMessageParameters (previously the parent ApplicationMessageParameters), so the dedicated parameters class is finally wired into the handler.
  • ApplicationExceptionsHandler.handleRequest now reads UpperLimitExceptionParameter from the request and applies the limit when constructing the response, mirroring JobExceptionsHandler.
  • archiveApplicationWithPath uses a MAX_NUMBER_EXCEPTION_TO_REPORT = 20 default when archiving JSON (no client query available at archive time), matching the job-side archive behavior.
  • Added an int maxSize argument to ApplicationExceptionsInfoWithHistory.fromApplicationExceptionHistory(...) that limits the rendered history via .limit(maxSize).
  • Flipped upperLimitExceptionParameter on ApplicationExceptionsMessageParameters from private final to public final, so callers can resolve it via the typed REST client — mirroring the change made for the job endpoint in FLINK-39711.

Verifying this change

This change is covered by updated unit tests:

  • ApplicationExceptionsHandlerTest — new test testMaxExceptionsLimitsHistorySize builds an archived application with 5 exceptions, sets maxExceptions=2 via the typed parameters, and asserts the handler returns exactly 2 entries. Existing tests in the same class were migrated to use ApplicationExceptionsMessageParameters instead of ApplicationMessageParameters to match the handler's new generic type.
  • Existing JobExceptionsHandlerTest continues to validate the analogous server-side behavior on the job endpoint, confirming the application change brings the two endpoints into parity.

REST API stability snapshot and generated reference docs were regenerated to reflect the newly-declared maxExceptions query parameter on /applications/:applicationid/exceptions:

  • flink-runtime-web/src/test/resources/rest_api_v1.snapshot
  • docs/static/generated/rest_v1_dispatcher.yml
  • docs/layouts/shortcodes/generated/rest_v1_dispatcher.html

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 — none of ApplicationExceptionsHandler, ApplicationExceptionsHeaders, ApplicationExceptionsMessageParameters, or ApplicationExceptionsInfoWithHistory carries an @Public / @PublicEvolving annotation. The generic-type-parameter switch is technically observable to any caller constructing these classes directly, but they are runtime-internal types not part of Flink's stable user-facing API.
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery (JobManager, Checkpointing, Kubernetes/Yarn, ZooKeeper): no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes — the /applications/:applicationid/exceptions endpoint now honors the optional maxExceptions query parameter, consistent with the job-side endpoint.
  • If yes, how is the feature documented? Auto-generated REST reference docs (rest_v1_dispatcher.yml / rest_v1_dispatcher.html) — regenerated in this PR alongside the code changes.

Was generative AI tooling used to co-author this PR?

  • Yes — Claude was used as a pair-programming assistant for discussing the approach and implementation structure. All code was written, understood, and verified by the author.

Generated-by: Claude Opus 4.7

…ndler

ApplicationExceptionsHandler did not read the maxExceptions query parameter from the request, and ApplicationExceptionsHeaders was typed on ApplicationMessageParameters (parent) rather than ApplicationExceptionsMessageParameters, leaving the latter as orphaned scaffolding from FLINK-38977. As a result, typed Java REST clients setting maxExceptions on the application endpoint had the parameter silently discarded by the server.
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented May 22, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

jubins added a commit to jubins/flink that referenced this pull request May 23, 2026
Addresses review feedback on the FLINK-39711 PR:

- Revert visibility change on ApplicationExceptionsMessageParameters and remove its test. The application-side parameter is silently discarded by ApplicationExceptionsHandler today; the full server-side fix is being handled in apache#28226 (FLINK-39730), so exposing the field here would land an incomplete state where clients can set a parameter the server ignores.
- Revert visibility change on JobExceptionsMessageParameters.failureLabelExceptionParameter and remove testFailureLabelFilterQueryParameterIsRendered. failureLabelFilter exposure wasn't part of the JIRA scope; it was added for parity but surfaces a pre-existing FailureLabel.toString rendering quirk that deserves its own ticket.
- Change test value in testMaxExceptionsQueryParameterIsRendered from 20 to 5 so the value is distinguishable from MAX_NUMBER_EXCEPTION_TO_REPORT (the server-side default), making test intent unambiguous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants