[BUG] Exceptions in Background Callback Cause `InvalidCallbackReturnValue` When Using Custom Error Handler
@T4rk1n がすでに取り組んでいます。
2026年3月4日 から。
評価
この issue はまだ評価されていません。
説明
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.
- 主要言語
- Python
- スター
- 24.4k
- フォーク
- 2.3k
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 19
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
plotly/dash のほかの issue
-
good first issue P3 size: 1 task
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
enhancement P2 size: 5
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
-
enhancement P3 size: 10+
-
P2 size: 1 task
-
enhancement P3 size: 1
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
canonical/paas-charm#368 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
StevenBlack/hosts#3256 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
qualcomm/qai-appbuilder#275 ·