Callback Error Logs Should Include the Callback Function Name

Hello Dash team and community,

While working on a Dash application, I encountered limitation that makes debugging more difficult, especially in apps with many callbacks.

Problem

When an error occurs in a callback, Dash’s error message typically includes:

  • The component ID(s) involved,
  • The property that triggered the error, and
  • Sometimes, the output spec of the callback.

However, the error does not include:

  • The name of the Python function that implements the callback.

Since Dash uses decorators to register callbacks, and since Python functions retain their __name__, it seems technically feasible to include this information in the server-side logs or error messages.

Question

Has including the callback function name (or file/module location) in error logs been considered before?

This would make debugging significantly easier, especially in production or in large apps with reusable layouts and many callback definitions.

Suggestion

It would be helpful if:

  • Callback-related error logs could mention the callback function’s name,
  • Or provide a way to register callbacks with optional tags or identifiers for better tracing.

This would improve traceability and developer experience, particularly during production debugging.

Thanks for considering!

Hello @JohnBioinf,

For errors that are server side, you can use on_error and use traceback and log to whatever option you desire. The traceback will have the name, file, and all the stuff you need for tracking the issue.

1 Like

Thanks for the suggestion regarding server-side on_error handling and logging via traceback—that’s definitely useful when the error happens during callback execution on the Python side.

However, the kind of error I’m referring to occurs on the frontend (React side)—meaning the callback doesn’t even run—so on_error does not get triggered at all.

Here’s a minimal Dash example to illustrate this:

from dash import Dash, Input, Output, callback, dcc, html

app = Dash()

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"),
    ]
)

@callback(
    Output(component_id="my-output", component_property="children"),
    Input(component_id="my-input", component_property="foobar"),  # ❌ Invalid prop
)
def update_output_div(input_value):
    return f"Output: {input_value}"

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

This results in the following frontend error message:

⛑️Invalid prop for this component
Property "foobar" was used with component ID:
  "my-input"
in one of the Input items of a callback.
This ID is assigned to a dash_core_components.Input component
in the layout, which does not support this property.
This ID was used in the callback(s) for Output(s):
  my-output.children

As shown, the error provides:

  • The component ID (my-input)
  • The invalid property (foobar)
  • The Output(s) affected (my-output.children)

But it does not mention the callback function name—in this case, update_output_div—which is the key bit of context that would help a developer quickly locate the offending code.

My first question would be: Can this be achieved today? Maybe there is a community library or a sweet little hack. Otherwise, I would like to get some feedback on whether this is a useful feature and whether I should open an issue on github for improvement. I found this especially annoying as the app grows and I use reusable layouts, dynamically generated IDs etc.

@JohnBioinf,

I’m struggling with the usefulness of this specific callback as this wouldnt be something that you’d see in a real production environment.

However, I have been messing around with altering the window onerror and unhandled promise, console warning and error to send to the backend for errors.

Hey, thanks for your insights. But why don’t you see this as useful? I often struggle to find the callback that has the named inputs, especially when I set the ids dynamically. But maybe this is just my quirky code.

But for this handling of java script errors there is only the built in debug frontend? There is no way to redirect these errors back to the flask server? I asked ChatGPT about this and they only came up with a custom solution which looked realy unorthodox to me (setting up a flask route and injecting some java script). I thought this would be a better solution.

I wasn’t saying that the JS error catching wouldn’t be useful. I was stating that your example, of passing a prop that doesn’t exist, shouldn’t be in production because it would be in the development stage of the app that you are designing callbacks. :nerd_face:

What did you come up with as the script?