dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values for ..downtime.children...downtime_data.data...alert7.children... Expected 3, got 2

I have a call back with multiple output values inside a list. When I deploy the app and check the logs, it throws a dash exception .

ontrols = dbc.FormGroup(

    [

        dbc.Row([

            dbc.Col(

            html.Div(["Start Time: ", constants.start_date_picker],

                    ),

                ),

            dbc.Col(

                html.Div([ constants.start_time_picker ])

            )

        ],style={"marginBottom":"0.5em"}),

                dbc.Row([

            dbc.Col(

            html.Div(["End Time: ", constants.end_date_picker]),

                ),

            dbc.Col(constants.end_time_picker 

                ),

        ]),

     html.Hr(),

    dbc.Row([

         dbc.Col([

                     html.Div(["Database"])

             ]),

         dbc.Col([

                     constants.database

             ])

     ],style={"marginBottom":"1em"}),          

    dbc.Row([

    ],style={"marginBottom":"1em"}),

    dbc.Row([

        dbc.Col([

                    html.Div(["Language"])

            ]),

        dbc.Col([

                    constants.language

            ])

    ],style={"marginBottom":"0.5em"}),

    html.Hr(),

    dbc.Button(

        id='submit_button',

        n_clicks=0,

        children='Submit',

        color='primary',

        block=True

        ),

    html.Hr(),

    html.Div(id="alert7"),

    html.Div(id="link7"),

    # html.Div(id="bar7")

    ]

)

sidebar = html.Div(

    [

        html.H2('Parameters', style=constants.TEXT_STYLE),

        # html.H3('Parameters', style=constants.TEXT_STYLE),

        html.Hr(),

        controls

    ],

    style=constants.SIDEBAR_STYLE,

)

content = html.Div(

    [

        dcc.Tabs([

            dcc.Tab(label='Report', children=[

                dcc.Store(id="downtime_data"),

                html.Div(id="downtime", style={"display" : "none"}),

                # dcc.Store(id="total_number_of_parts"),

                # dcc.Store(id="new_intermediate_values"),

                # html.Div(id='produktionsdaten', style={'display': 'none'}),

                # html.Div(id='file_dates', style={'display': 'none'}),

                # dcc.Store(id="Bar_chart_link"),

                # dcc.Store(id="Pie_chart_link"),

                # html.Div(id="table1"),

                # dcc.Store(id="Report_link"),

                # dcc.Store(id="excel_data_error_log"),

                html.Hr(),

                dbc.Row([

                    # dbc.Col([

                    #     html.Div(children=html.Strong(id='fehler_zahl'))

                    # ]),

                    # dbc.Col([

                    #     html.Div(children=html.Strong(id='fehler_dauer'))

                    # ]),

                    # dbc.Col([

                    #     html.Div(children=html.Strong(id='verlust_menge'))

                    # ])

                ],style={"marginBottom":"0.5em"}),

                # dbc.Row([

                #     dbc.Col([

                #         html.Div(children=html.Strong(id='ok_parts'))

                #     ]),

                #     dbc.Col([

                #         html.Div(children=html.Strong(id='faulty_parts'))

                #     ]),

                #     dbc.Col([

                #         html.Div(children=html.Strong(id='mean_cycle_time'))

                #     ])

                # ])

            ]),

        dcc.Tab(label='Bar Chart', children=[

                dcc.Graph(id="bar_chart", style={"height":800}),

            ]),

            dcc.Tab(label='Pie Chart', children=[

                dcc.Graph(id="pie_chart", style={"height":800}),

            ]),

        ]),

    ],

    style=constants.CONTENT_STYLE,

    id="content"

)

# content = html.Div(

#     [

#         html.H1("Downtime data", style={"text-align": "center"}),

#         dcc.Store(id="downtime_data"),

#         html.Div(id="downtime")

#     ],

#     style=constants.CONTENT_STYLE,

#     id="content"

# )

layout = html.Div([sidebar, content])

this is my callback:

@app.callback([

    Output("downtime", "children"),

    Output("downtime_data", "data"),

    Output("alert7", "children")

    ],

        # Ide sve sto vidimo sa lijeve strane ispod parametara,to se samo nadodaje to je ustavri sad input informacija

        [Input("submit_button", "n_clicks")],

        state=[State("start_date_picker", "date"),

        State("start_time_picker", "value"),

        State("end_date_picker", "date"),

        State("end_time_picker", "value"),

        State("database", "value"),

        State("language", "value")]

)

        

def fetch_the_downtime(n_clicks, start_date_picker, start_time_picker, end_date_picker, end_time_picker, database, language):

    if n_clicks:

        start_time = datetime.datetime.strptime(start_date_picker, "%Y-%m-%d") + datetime.timedelta(hours=int(start_time_picker[0:2]))

        end_time = datetime.datetime.strptime(end_date_picker, "%Y-%m-%d") + datetime.timedelta(hours=int(end_time_picker[0:2]))

        parameters = [start_time, end_time]

    # if not n_clicks:

    #     db_query_string = """"SELECT NotificationLog.ID as 'ID',

    #                     DAY(Timestamp) as 'DAY',

    #                     MONTH(Timestamp) as 'MONTH',

    #                     NotificationLog.Duration,

    #                     DATEPART(WEEK, NotificationLog.Timestamp)-1 as 'Week Number'

    #                     FROM NotificationLog

    #                         BETWEEN ? AND ?"""

        query_string = mssql_queries.build_db_query_app7()

        records = mssql_conn.execute_query(query_string, parameters, str(database))

        print()

        if records:

            dataframe = pd.DataFrame.from_records(records)

            dataframe.columns = ["ID", "DAY", "MONTH", "Duration", "Week Number"]

            mask = dataframe.applymap(type) != bool

            d = {True: "1", False: "0"}

            dataframe = dataframe.where(mask, dataframe.replace(d))

            print("----")

            print(dataframe)

            return dbc.Table.from_dataframe(dataframe), dataframe.to_json(date_format="iso", orient="split")

        else:

            return None, None, dbc.Alert("No entries within the specified timeframe.", color="warning", duration=5000)

    else:

        return dbc.Table(None), None, None

And the error:

Traceback (most recent call last):
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\flask\app.py”, line 1513, in full_dispatch_request
rv = self.dispatch_request()
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\flask\app.py”, line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\dash_auth\basic_auth.py”, line 33, in wrap
response = f(*args, **kwargs)
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\dash\dash.py”, line 1096, in dispatch
response.set_data(func(*args, outputs_list=outputs_list))
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\dash\dash.py”, line 1027, in add_context
_validate.validate_multi_return(output_spec, output_value, callback_id)
File “C:\Users\denis.akvic\AppData\Local\Programs\Python\Python39\Lib\site-packages\dash_validate.py”, line 147, in validate_multi_return
raise exceptions.InvalidCallbackReturnValue(
dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values for …downtime.children…downtime_data.data…alert7.children…
Expected 3, got 2

Hi @Traxdata

The error is likely from this return statement:

return dbc.Table.from_dataframe(dataframe), dataframe.to_json(date_format="iso", orient="split")

There are only two items returned here, but the callback has 3 Outputs

Thank you very much!It works now