Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

CallbackFailedException throws NullPointerException when a failed callback has no Error

Open Beginner friendly
#773 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java

Research direction

Start with CallbackFailedException.buildMessage and the call sites in CallbackOperation.get() and ChildContextOperation; check how existing tests construct a failed callback operation. Add a unit test for a failed callback with no CallbackDetails.Error, and verify it throws CallbackFailedException with the message Callback failed rather than NullPointerException.

Written by the indexing model from the issue text.

Description

bug pkg:sdk
Description

SendDurableExecutionCallbackFailure accepts a request with no Error because the field is optional. A callback that is failed this way reaches the SDK as a CALLBACK operation with Status: FAILED and no CallbackDetails.Error.

On that operation, CallbackOperation.get() throws new CallbackFailedException(op):

https://github.com/aws/aws-durable-execution-sdk-java/blob/7f1a73ca16308d31a1e5a270e504676caf890e0b/sdk/src/main/java/software/amazon/lambda/durable/operation/CallbackOperation.java#L80

The constructor passes operation.callbackDetails().error() to buildMessage. That method calls error.errorType() without a null check:

https://github.com/aws/aws-durable-execution-sdk-java/blob/7f1a73ca16308d31a1e5a270e504676caf890e0b/sdk/src/main/java/software/amazon/lambda/durable/exception/CallbackFailedException.java#L14-L15

So the handler gets a NullPointerException instead of CallbackFailedException, and a catch (CallbackFailedException e) block does not catch it. ChildContextOperation builds the same exception, so the same failure can occur there:

https://github.com/aws/aws-durable-execution-sdk-java/blob/7f1a73ca16308d31a1e5a270e504676caf890e0b/sdk/src/main/java/software/amazon/lambda/durable/operation/ChildContextOperation.java#L292

Steps to reproduce
  1. Create a callback in a durable handler and call get() on it.
  2. Call SendDurableExecutionCallbackFailure for that callback ID with no Error in the request body.
  3. On replay, get() throws NullPointerException from CallbackFailedException.buildMessage.
Expected behavior

get() throws CallbackFailedException with the message "Callback failed". This matches the reference JS implementation, which falls back to new CallbackExternalError("Callback failed") when Error is absent:

https://github.com/aws/aws-durable-execution-sdk-js/blob/0ee6c027ca3b58f3bf270fdf4a9ac87b73752467/packages/aws-durable-execution-sdk-js/src/handlers/callback-handler/callback.ts#L248-L273

Suggested fix

Handle a null ErrorObject in buildMessage:

private static String buildMessage(ErrorObject error) {
    if (error == null) {
        return "Callback failed";
    }
    var errorType = error.errorType();
    var errorMessage = error.errorMessage() != null ? error.errorMessage() : "Callback failed";
    if (errorType != null && !errorType.isEmpty()) {
        return errorType + ": " + errorMessage;
    }
    return errorMessage;
}

The errorMessage fallback also covers an Error that is present but has no message. JS uses error.ErrorMessage || "Callback failed" for that case.

DurableOperationException already accepts a null ErrorObject, so no other change is needed. Add a unit test for a FAILED callback operation with no CallbackDetails.Error.

Dominant language
Java
Stars
28
Forks
13
Avg merge
2d 8h
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-durable-execution-sdk-java

All issues in aws/aws-durable-execution-sdk-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.