dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values Expected 2, got 1

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.

app.layout = html.Div([

    # header

    # For pdf downloads




               Output('page-content', 'children'),
               Output('download', 'data')
              [Input('url', 'pathname')]
def display_content(page_name):

    # Pages and Links

    if page_name == 'history':
        return [history.layout(), dash.no_update]

        return ['404 Error', dash.no_update]

Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/app/.heroku/python/lib/python3.6/site-packages/dash/dash.py", line 1050, in dispatch
response.set_data(func(*args, outputs_list=outputs_list))
File "/app/.heroku/python/lib/python3.6/site-packages/dash/dash.py", line 995, in add_context
_validate.validate_multi_return(output_spec, output_value, callback_id)
File "/app/.heroku/python/lib/python3.6/site-packages/dash/_validate.py", line 126, in validate_multi_return
callback_id, len(outputs_list), len(output_value) - - [03/Sep/2020:06:03:32 +0000] "POST /dash-app/_dash-update-component HTTP/1.1" 500 69 "https://example.com/dash-app" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"

dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values for ..page-content.children...download.data...

Hi @keval

Try removing the [ ] from the return statements. That should fix that error message.

That’s strange, lists in returns used to work fine. Is this a change in dash 1.15 maybe?

Actually, a list still works fine - I just checked it. I don’t normally do it that way and thought that was the problem.

Yeah, lists should work. Removing the list throws:

Expected the output type to be list or tuple, but got None.

It seems like you are missing a ’ after history, i.e. instead of

if page_name == 'history:

it should be

if page_name == 'history':

Or is that just a copy-paste error?

Copy paste error. The exception is Invalid callback.