Skip to content

Error when using dash-auth and pattern-matching callbacks simultaneously #147

@Pierlou

Description

@Pierlou

Hi,

Thanks for this lib! I am building a rather simple app and I have bumped into an error with these steps:

  1. use dash auth to put the app behind a login requirement
auth = dash_auth.BasicAuth(
    app,
    VALID_USERNAME_PASSWORD_PAIRS
)
  1. create a callback that uses an undefined number of inputs using the pattern-matching mechanism:
@app.callback(
    Output("tmp_output", "children"),
    [Input({'type': 'certify', 'index': dash.ALL}, 'n_clicks')],
    prevent_initial_call=True,
)
def print_output(*args):
    print(args)
    return str(args)

where all inputs are clicks from an unknown number of buttons which ids are {'type': 'certify', 'index': f'certif:button_{s}'} (with s being a parameter from a list built within another callback).

If I uncomment the auth part or this specific callback, everything works like a charm, otherwise I am getting:

  File "...\lib\site-packages\dash_auth\auth.py", line 72, in <genexpr>
    if inp["property"] == "pathname"
  TypeError: list indices must be integers or slices, not str

When going to the specific part of the code it appears (if I understand it correctly), that it is not expecting that the input can be multiple, is that right? In my case, if I print [inp for inp in body["inputs"]] right before the error is raised, I get a list of a list inputs, which could mean that the code could go one step deeper in case the inputs are multiple.

I hope this context helps (and that I am not missing an issue from my code).

Versions:

dash==2.11.1
dash_auth==2.2.0

FYI @mikoa9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions