plotly / plotly/dash

[BUG] ctx.triggered_id is not recognized as a dict

Open
#3,968 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3 size: 1 task
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

dash                      4.4.1
dash_ag_grid              35.3.0
dash-extensions           2.0.6
dash-iconify              0.1.2
dash_mantine_components   2.8.0

Describe the bug

I am defining multiple dynamic components and set their id like this:

id={"type": "entry", "index": id},

where the value of "index" gets changed depending on the component.
Now, when I want to use the id in a pattern-matching callback, I need to get the value of "index"to search a sqlite database. When I use

ctx.triggered_id.get("index"))

however, VS Code produces an error and says: ""get" is no known attribute of "None"". The call however correctly returns the value of "index"

The same problem happens with ctx.triggered_id["index"], although the error then says: "None" object is not subscriptable.

FYI: I translated the error messages from German to English. They could be slightly inaccurate, though their meaning should be correct

Expected behavior

I would expect it to see a dict as a possible type of triggered_id, so that there is no error shown.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file or test; start at the Python definition of ctx.triggered_id and the callback-context typing. Reproduce pattern-matching access with the listed Dash versions, then verify that static analysis permits dictionary access while the no-trigger case remains represented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
63/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.