A nonexistent object was used in an Input” after generating a report in a multi-page Dash app

Hello,

I am receiving the following callback error in a multi-page Plotly Dash application after generating a report:

A nonexistent object was used in an `Input` of a Dash callback.

The id of this object is `moe-generate-report-button`
and the property is `n_clicks`.

However, the list of component IDs in the current layout includes:

ma-generate-report-button

It does not include:

moe-generate-report-button

The relevant callback input is similar to:

Input("moe-generate-report-button", "n_clicks")

The component currently rendered on the page uses:

id="ma-generate-report-button"

This application contains multiple report pages, and some layouts are loaded dynamically. The error appears after I generate the report or navigate to the Machine Activity report page.

I would like to understand the recommended way to handle this situation:

  1. Should each report page have a separate callback using only the component IDs present in that page’s layout?
  2. If a callback needs components from different pages, should I define app.validation_layout containing all page layouts?
  3. Is suppress_callback_exceptions=True appropriate here, or does the callback still need to avoid referencing components that are absent from the currently rendered layout?
  4. Could this error be caused by an incorrect or outdated component ID, since the callback uses the moe- prefix while the current page uses the ma- prefix?

My current configuration includes:

app = Dash(
    __name__,
    suppress_callback_exceptions=True
)

Environment:

Dash: 3.4.0
Python: 3.11.15
Operating system: Windows

I have attached a screenshot of the full browser error. Please let me know if a minimal reproducible example or the complete callback definition would help.

Hi @Utsav_Prajapati

This is fairly common in multi-page Dash apps. It happens when an output on one page updates a component that is an Input to a callback on another page. That update triggers the callback, but if the other page isn’t active, the input component doesn’t exist in the layout, causing the error.

Check out this section in the docs about making inputs optional.

If that doesn’t solve the issue, then a minimal example would be helpful.