Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Callback Ignoring Input and getting TypeError: missing 1 required positional argument: error

I am following the example on https://dash.plotly.com/sharing-data-between-callbacks and have a hidden div in my layout as:

html.Div(sid, id='session_id', style={'display': 'none'}),

with sid as a randomly defined string.

I have one callback that is working great:

@app.callback(
    [Output('graph-gains', 'children'),
     Output('table-gains', 'children'),
     Output('dps-gains', 'max_date_allowed'),
     Output('dps-gains', 'initial_visible_month'),
     Output('interval-gains', 'interval'),
     Output('msg_dbg-gains', 'children')],
    # sym, ix, date come straight from the control elements
    [Input('dd_sym-gains', 'value'),
     Input('dd_ix-gains', 'value'),
     Input('dps-gains', 'date'),
     Input('tabs-gains', 'active_tab'),
     Input('session_id', 'children'),
     Input('interval-gains', 'n_intervals')])
def callback_main_gains(sym, ix, date, period, sid, nint):

sid is passed as the fifth argument to my function and works correctly. However I am trying to add it into a second callback:

@app.callback(
    [Output('msg-feedback', 'children'),
     Output('textarea-feedback', 'value')],
    [Input('button_submit-feedback', 'n_clicks')],
    [State('textarea-feedback', 'value'),
     State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, feedback, ddm):

also works without session-id, but adding it in and adding a sid argument as follows:

@app.callback(
    [Output('msg-feedback', 'children'),
     Output('textarea-feedback', 'value')],
    [Input('button_submit-feedback', 'n_clicks'),
     Input('session_id', 'children')],
    [State('textarea-feedback', 'value'),
     State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, sid, feedback, ddm):
    return self.callback_main_feedback(n_clicks, sid, feedback, ddm)

gives me the following error when I click the page:

TypeError: callback_main_feedback() missing 1 required positional argument: 'ddm'

When I remove the sid argument, but not the Input(‘session_id’, ‘children’) Input:

@app.callback(
    [Output('msg-feedback', 'children'),
     Output('textarea-feedback', 'value')],
    [Input('button_submit-feedback', 'n_clicks'),
     Input('session_id', 'children')],
    [State('textarea-feedback', 'value'),
     State('ddm-feedback', 'label')]
)
def callback_main_feedback(n_clicks, feedback, ddm):
    return self.callback_main_feedback(n_clicks, feedback, ddm)

It doesn’t error but behaves as if Input(‘session_id’, ‘children’)] simply isn’t there.

I have tried this in two other callbacks. One that is a mirror-image of the working example is also is working correctly. Adding it into a fourth one is not working in the manner I’ve just described,

Any ideas what I am doing wrong here?

figured this one out myself (again). I had suppress_callback_exceptions=True set which just made things weird for when errors fired and when they didn’t (mostly didn’t). After setting this to False, the errors properly led me in the right direction.

What was the issue? I’m running into the same problem.

one or more incorrectly named id strings either in my callback or layout (probably layout). Setting suppress_callback_exceptions=False and debug=True in the app.run_server call should throw an error point out what’s wrong. I was struggling for a little while with both set the other way around.