Skip to content

Report missing activity timeout as BAD_REQUEST inside a Nexus operation handler - #3045

Open
tekkaya wants to merge 1 commit into
mainfrom
nexus-missing-timeout-bad-request
Open

Report missing activity timeout as BAD_REQUEST inside a Nexus operation handler#3045
tekkaya wants to merge 1 commit into
mainfrom
nexus-missing-timeout-bad-request

Conversation

@tekkaya

@tekkaya tekkaya commented Aug 28, 2026

Copy link
Copy Markdown

What was changed

NexusTaskHandlerImpl.convertKnownFailures now maps any IllegalArgumentException thrown by
Nexus operation handler code to HandlerException(BAD_REQUEST).

Why?

StartActivityOptions.Builder.build() throws a plain IllegalArgumentException when neither
scheduleToCloseTimeout nor startToCloseTimeout is set. Thrown from inside a Nexus operation
handler, that isn't a recognized Nexus error type, so it fell through to the generic
HandlerException(INTERNAL) catch-all in NexusTaskHandlerImpl.handle() — the caller then
retries until the operation's schedule-to-close timeout expires, instead of failing fast.

Checklist

  1. Closes: A gap found during Nexus SAA Test Plan execution for Temporal Java SDK

  2. How was this tested:
    Added NexusTaskHandlerImplTest.startTaskHandlerMissingBothActivityTimeoutOptions, which registers
    a handler that throws IllegalArgumentException, and asserts the response comes back as HandlerException(BAD_REQUEST).

  3. Any docs updates needed?
    No.

@tekkaya
tekkaya marked this pull request as ready for review August 28, 2026 17:32
@tekkaya
tekkaya requested a review from a team as a code owner August 28, 2026 17:32
…on handler

Previously, building StartActivityOptions with neither scheduleToCloseTimeout
nor startToCloseTimeout set always threw a plain IllegalArgumentException.
When that build() call happens inside a Nexus operation handler, that
exception isn't a recognized Nexus error type, so NexusTaskHandlerImpl's
catch-all surfaced it as an opaque HandlerException(INTERNAL), which the
caller retries until the operation's schedule-to-close timeout expires
instead of failing fast.

NexusTaskHandlerImpl.convertKnownFailures now maps any IllegalArgumentException
raised by handler code to a real HandlerException(BAD_REQUEST), matching the
pattern already used for header/operation-token parsing elsewhere in this
class and in TemporalOperationHandler/WorkflowRunOperationImpl. This fixes the
missing-timeout case without teaching the general-purpose, Nexus-agnostic
StartActivityOptions builder about Nexus, and it also covers every other
IllegalArgumentException a Nexus operation handler can throw (missing id,
empty task queue, negative start delay, etc.) with one change, regardless of
whether the handler is built via TemporalOperationHandler or a raw/sync
OperationHandler.
@tekkaya
tekkaya force-pushed the nexus-missing-timeout-bad-request branch from 07289a9 to b615451 Compare August 28, 2026 17:46
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.

1 participant