From 87f75d7f1632e2b3faa08a2554e625aedbacd875 Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 6 Sep 2024 12:14:45 -0400 Subject: [PATCH 1/2] Fix error handler and grouped outputs --- dash/_callback.py | 5 +---- .../callbacks/test_callback_error.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dash/_callback.py b/dash/_callback.py index 08314cc63a..383ce6886d 100644 --- a/dash/_callback.py +++ b/dash/_callback.py @@ -509,10 +509,7 @@ def add_context(*args, **kwargs): # If the error returns nothing, automatically puts NoUpdate for response. if output_value is None: - if not multi: - output_value = NoUpdate() - else: - output_value = [NoUpdate() for _ in output_spec] + output_value = NoUpdate() else: raise err diff --git a/tests/integration/callbacks/test_callback_error.py b/tests/integration/callbacks/test_callback_error.py index 0a76ed741d..2b6d701111 100644 --- a/tests/integration/callbacks/test_callback_error.py +++ b/tests/integration/callbacks/test_callback_error.py @@ -10,9 +10,12 @@ def global_callback_error_handler(err): app.layout = [ html.Button("start", id="start-local"), html.Button("start-global", id="start-global"), + html.Button("start-grouped", id="start-grouped"), html.Div(id="output"), html.Div(id="output-global"), html.Div(id="error-message"), + # test for #2983 + html.Div("default-value", id="grouped-output"), ] def on_callback_error(err): @@ -36,6 +39,14 @@ def on_start(_): def on_start_global(_): raise Exception("global error") + @app.callback( + output=dict(test=Output("grouped-output", "children")), + inputs=dict(start=Input("start-grouped", "n_clicks")), + prevent_initial_call=True, + ) + def on_start_grouped(start=0): + raise Exception("grouped error") + dash_duo.start_server(app) dash_duo.find_element("#start-local").click() @@ -44,3 +55,9 @@ def on_start_global(_): dash_duo.find_element("#start-global").click() dash_duo.wait_for_text_to_equal("#output-global", "global: global error") + + dash_duo.find_element("#start-grouped").click() + dash_duo.wait_for_text_to_equal("#output-global", "global: grouped error") + dash_duo.wait_for_text_to_equal("#grouped-output", "default-value") + + assert dash_duo.get_logs() == [] From b0acdfa161feb5101497fbfe53c6a8757900866b Mon Sep 17 00:00:00 2001 From: philippe Date: Fri, 6 Sep 2024 12:56:56 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1bdcead42..fc1c4a163e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## Fixed - [#2987](https://github.com/plotly/dash/pull/2987) Fix multioutput requiring same number of no_update. Fixes [#2986](https://github.com/plotly/dash/issues/2986) +- [2988](https://github.com/plotly/dash/pull/2988) Fix error handler and grouped outputs. Fixes [#2983](https://github.com/plotly/dash/issues/2983) ## Deprecated