Skip to content

[BUG] Use of "id" in Pattern Matching Callbacks breaks args_grouping #2086

@MrTeale

Description

@MrTeale

Describe your context
Currently running on Python 3.9.10 on MacOS Monterey (12.3.1) with the below dash libraries installed

dash                 2.5.0
dash-core-components 2.0.0
dash-cytoscape       0.3.0
dash-daq             0.5.1
dash-html-components 2.0.0
dash-table           5.0.0

Describe the bug

Using id as a key within a component's id breaks the new callback context's args_grouping function. An example of a component within my use cases looks like:

dcc.Store(id={"id": "A-store", "type": "scenario"}, storage_type="local"),
dcc.Store(id={"id": "B-store", "type": "scenario"}, storage_type="local"),
dcc.Store(id={"id": "C-store", "type": "scenario"}, storage_type="local"),

and the callback Input looks like:

Input({"type": "scenario", "id": ALL}, "data"),

Output Traceback from Error (apologies, I've had to hide some personal file paths):

Traceback (most recent call last):
  File ".....", line 172, in update_graph
    pprint(ctx.args_grouping)
  File "/Users/...../.venv_core/lib/python3.9/site-packages/dash/_callback_context.py", line 18, in assert_context
    return func(*args, **kwargs)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 182, in args_grouping
    recursive_update(grouping)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 180, in recursive_update
    recursive_update(i)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 179, in recursive_update
    update_args_grouping(i)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 157, in update_args_grouping
    prop_id = f"{str_id}.{g['property']}"
KeyError: 'property'

Expected behavior

The ability to use any key within a pattern matching ID and still have args grouping working or this limitation documented within the Dash Docs. Current documentation recommends using type, index or id as keys for readability, so this would need to change.

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