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

exception handling mechanism for using keyword parameters to orchestrate callbacks reported an error #2983

Closed
insistence opened this issue Sep 5, 2024 · 0 comments · Fixed by #2988
Assignees
Labels
bug something broken P2 considered for next cycle

Comments

@insistence
Copy link
Contributor

insistence commented Sep 5, 2024

Hi, there.
I encountered a bug while using the exception handling feature in version 2.18.
Dash related information is as follows

dash                          2.18.0
dash-core-components          2.0.0
dash-html-components          2.0.0
dash-table                    5.0.0

The test code is as follows

from dash import Dash, html, Input, Output, set_props


def global_callback_error_handler(err):
    set_props('output-global', {'children': f'global: {err}'})


app = Dash(on_error=global_callback_error_handler)

app.layout = [
    html.Button('start', id='start-local'),
    html.Button('start-global', id='start-global'),
    html.Div(id='output'),
    html.Div(id='output-global'),
    html.Div(id='error-message'),
]


def on_callback_error(err):
    set_props('error-message', {'children': f'message: {err}'})
    return dict(test=f'callback: {err}')


@app.callback(
    output=dict(test=Output('output', 'children')),
    inputs=dict(start=Input('start-local', 'n_clicks')),
    on_error=on_callback_error,
    prevent_initial_call=True,
)
def on_start(start):
    raise Exception('local error')


@app.callback(
    output=dict(test=Output('output-global', 'children')),
    inputs=dict(start=Input('start-global', 'n_clicks')),
    prevent_initial_call=True,
)
def on_start_global(start):
    raise Exception('global error')


if __name__ == '__main__':
    app.run(debug=True)

The error message is as follows

dash._grouping.SchemaTypeValidationError: Schema: {'test': <Output `output-global.children`>}
Path: ()
Expected type: <class 'dict'>
Received value of type <class 'list'>:
    [<dash._callback.NoUpdate object at 0x00000215C014BF40>]

It seems to return a list containing NoUpdate by default.

@T4rk1n T4rk1n self-assigned this Sep 5, 2024
@gvwilson gvwilson changed the title [BUG] In version 2.18, the exception handling mechanism for using keyword parameters to orchestrate callbacks reported an error exception handling mechanism for using keyword parameters to orchestrate callbacks reported an error Sep 5, 2024
@gvwilson gvwilson added bug something broken P2 considered for next cycle labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 considered for next cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants