firebase-admin-java icon indicating copy to clipboard operation
firebase-admin-java copied to clipboard

Errors inside the SDK are not reported to the callback

Open chrylis opened this issue 1 year ago • 2 comments
trafficstars

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.

chrylis avatar Jun 21 '24 20:06 chrylis

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

google-oss-bot avatar Jun 21 '24 20:06 google-oss-bot

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 }

Mohima6 avatar Mar 21 '25 06:03 Mohima6