Exception on "raise PreventUpdate"

Hi everyone,

this is one of those “overnight” bugs, where you come back to your project and for no reason there is a bug, which was not there before: whenever I use “raise PreventUpdate”, I get an Exception saying “exception: no description”. This even happens in the simplest of examples, which I have included below. PreventUpdate is triggered (and the exception thrown), when the Input has less than 5 characters.

As a result of this bug I have updated all my dash related libraries to the newest version, but the error prevails.

import dash
from dash import dcc
from dash import html as html
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate

external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div(
    [
        html.H6("Change the value in the text box to see callbacks in action!"),
        html.Div(
            ["Input: ", dcc.Input(id="my-input", value="initial value", type="text")]
        ),
        html.Br(),
        html.Div(id="my-output"),
    ]
)


@app.callback(
    Output(component_id="my-output", component_property="children"),
    Input(component_id="my-input", component_property="value"),
)
def update_output_div(input_value):
    if len(input_value) < 5:
        raise PreventUpdate
    return "Output: {}".format(input_value)


if __name__ == "__main__":
    app.run_server(debug=True)

Advice is very much appreciated!

Best regards

Fixed it, stupid mistake.

vscode_settings_dash

Either by accident or by updating VS Code the “User Uncaught Exceptions” breakpoint had been set in my IDE. Since PreventUpdate is internally handled as an exception, I saw that “error message” whenever “raise PreventUpdate” was reached. I mistook it for an error on my end, whereas it actually is intended behaviour.