Skip to content

Errors inside the SDK are not reported to the callback #963

@chrylis

Description

@chrylis

In debugging #962, I found that the error was not passed back to the callback, which prevents proper debugging in deployment. In addition to logging the error, the error should have been passed to the callback.

Activity

google-oss-bot

google-oss-bot commented on Jun 21, 2024

@google-oss-bot

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Mohima6

Mohima6 commented on Mar 21, 2025

@Mohima6

Root Cause:

  1. Errors were only logged inside the SDK but were not passed to the callback, preventing proper error handling and debugging.
    2)This made it difficult for developers to catch exceptions and react accordingly.

Fix Implemented:
Modified the SDK to ensure that errors are passed to the callback properly.
Before Fix: Errors were only logged and never returned to the callback. Calling an SDK function that triggers an error.
After Fix: Errors inside the SDK are now passed to the callback, not just logged.

Code to fix:

try {
someAsyncOperation(new Callback() {
@OverRide
public void onSuccess(Result result) {
callback.onSuccess(result); // Pass successful result
}

    @Override
    public void onFailure(Exception e) {
        log.error("Error occurred: " + e.getMessage(), e);  // Log error
        callback.onFailure(e);  // Now forwarding error to callback
    }
});

} catch (Exception e) {
log.error("Unhandled exception: " + e.getMessage(), e);
callback.onFailure(e); // Ensure callback receives error
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chrylis@google-oss-bot@Mohima6

        Issue actions

          Errors inside the SDK are not reported to the callback · Issue #963 · firebase/firebase-admin-java