Skip to content

Commit

Permalink
Merge pull request #2988 from plotly/fix/2983
Browse files Browse the repository at this point in the history
Fix error handler and grouped outputs
  • Loading branch information
T4rk1n authored Sep 6, 2024
2 parents 354d1a0 + b0acdfa commit f04613c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions tests/integration/callbacks/test_callback_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()

Expand All @@ -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() == []

0 comments on commit f04613c

Please sign in to comment.