Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error handler and grouped outputs #2988

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() == []