Skip to content

fix: handle None return from error handler in no-output background callbacks - #4012

Open
dajiaohuang wants to merge 2 commits into
plotly:devfrom
dajiaohuang:fix/3628-background-callback-error-handler
Open

dajiaohuang wants to merge 2 commits into
plotly:devfrom
dajiaohuang:fix/3628-background-callback-error-handler

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

Summary

When a background callback with no outputs raises an exception, the error handler is called. If the error handler returns None, the code was incorrectly setting output_value = NoUpdate(), which then triggered an InvalidCallbackReturnValue exception at the output validation step.

Fix

This change adds the same output_spec check that exists in the non-background callback path to the background callback path at _callback.py:635, ensuring that NoUpdate() is only set when there are actual outputs to update.

Testing

The issue includes a minimal reproducible example that can be used to verify the fix.

Related Issue

Fixes #3628

…llbacks

When a background callback with no outputs raises an exception, the error
handler is called. If the error handler returns None, the code was
incorrectly setting output_value = NoUpdate(), which then triggered an
InvalidCallbackReturnValue exception at the output validation step.

This change adds the same output_spec check that exists in the non-background
callback path (line 866) to the background callback path (line 635), ensuring
that NoUpdate() is only set when there are actual outputs to update.

Fixes plotly#3628
@sonarqubecloud

Copy link
Copy Markdown

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.

[BUG] Exceptions in Background Callback Cause InvalidCallbackReturnValue When Using Custom Error Handler

1 participant