[BUG] Exceptions in Background Callback Cause `InvalidCallbackReturnValue` When Using Custom Error Handler
Les mainteneurs répondent en général sous 2 jours
Évaluation
Cette issue n'a pas encore été évaluée.
Description
Environment
- The server runs on Debian 13 on x86.
- Python 3.14.3 (main, Feb 3 2026, 22:52:18) [Clang 21.1.4 ] on linux
- The issue is not frontend-related.
Packages
dash 4.0.0
Bug Description
When using a custom error handler with a background callback with no outputs, exceptions raised in that callback cause an InvalidCallbackReturnValue exception to be raised.
Expected Behavior
Exceptions raised in the background callback are handled by the custom error handler. No further exceptions occur.
Actual Behavior
After the exception is handled by the custom error handler as expected, Dash’s error handling code replaces the output value with NoUpdate(). Later on the output value is expected to be None because the callback has no outputs, so an InvalidCallbackReturnValue exception is raised.
Minimal Working Example
- Install Dash and diskcache:
pip install dash[diskcache] - Create a file
main.pywith the following contents:import diskcache from dash import Dash, DiskcacheManager, Input, callback, dcc, html cache = diskcache.Cache("./cache") background_callback_manager = DiskcacheManager(cache) def custom_error_handler(err): print("The app raised an exception.") app = Dash( background_callback_manager=background_callback_manager, on_error=custom_error_handler, ) app.layout = html.Div( [ dcc.Input(id="input-number", type="number", value=1), ] ) @callback( Input("input-number", "value"), background=True, ) def update_output(_value): raise ValueError( "This exception is supposed to be caught by custom_error_handler and not shown " "in the developer tools." ) if __name__ == "__main__": app.run(debug=True) - Run the application:
python3.14 main.py - Open the web application in your browser:
firefox http://127.0.0.1:8050/ - Cause the exception by clicking a spinner button.
Analysis
The issue does not arise if background is set to False because the output of the error handler is treated differently in each case. In both cases, the error handler is called on the error and its return value is written to output_value.
- When
background=False,output_valueis left as is here becauseoutput_specis Falsy:if output_value is None and output_spec: output_value = NoUpdate() - When
background=True,output_valueis replaced here becauseoutput_specis not considered:if output_value is None: output_value = NoUpdate()
I do not know the rationale behind this decision, but it appears to break the intended behavior.
- Langage dominant
- Python
- Étoiles
- 24.4k
- Forks
- 2.3k
- Merge moyen
- 2 j 5 h
- PR mergées (30 j)
- 22
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de plotly/dash
-
P2 plotly-internal size: 1 task
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
Extract graph schema validation into properly named testPeut-être pris @Nice6042 l’a pris il y a 56 jours. Ouvertegood first issue P3 size: 1 task
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
plotly/dash#3735 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[BUG] dcc.Dropdown: hidden focus-target input is focusable inside aria-hidden and can overflow its wrapperPeut-être pris @KoolADE85 l’a pris il y a 4 jours. Ouvertebug P2 size: 1
Difficulté 4/5 3-5 jours Accessibilité débutants 56/100
plotly/dash#4042 · 3 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
Linter/Type Checking ReplacementOuverteP3 plotly-internal size: 10+ task
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
plotly/dash#4040 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
Drop Python 3.9 SupportOuverteP2 plotly-internal size: 5 task
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
plotly/dash#4038 · 2 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de plotly/dash
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
mishraprafful/multihull#150 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
python-caldav/caldav#735 ·
Les mainteneurs répondent en général sous 1 jour
-
bug triage
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
mealie-recipes/mealie#8682 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue lane:repo
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100