[BUG] Patch.update mutates a shared mapping and rewrites earlier merges

オープン
#4,143 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@peterolkhov がすでに取り組んでいます。

2026年11月12日 から。

  • #4144 @peterolkhov による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

Start by locating Patch.update and the code that records its merge operations; the issue provides a reproducer using a shared dictionary and to_json. Check the existing Patch tests for merge behavior, then verify that each location keeps its own amount and the input dictionary remains unchanged. Pull request #4144 is already open for this issue.

索引モデルが issue の本文から書いたものです。

説明

Patch.update uses its nonempty dictionary argument as the target for merging
keyword arguments. Reusing that dictionary for two locations in one callback
changes the value already queued for the first location.

import json

from dash import Patch
from dash._utils import to_json

common = {"currency": "USD"}
p = Patch()
p["jan"].update(common, amount=100)
p["feb"].update(common, amount=200)
print(json.dumps(json.loads(to_json(p)), indent=2))
print(common)

Expected merge values are {"currency": "USD", "amount": 100} for jan
and {"currency": "USD", "amount": 200} for feb. common should remain
{"currency": "USD"}. Both serialized merge values instead contain
"amount": 200, and common also gains "amount": 200.

The same callback was exercised in a running Dash app with a dcc.Store and
Chrome. Its actual Store data had amounts 200/200 instead of 100/200. Existing
fields at each location were retained. Distinct dictionary arguments and
keyword-only calls produced the expected 100/200 values.

The native diagnostic run is
https://github.com/peterolkhov/dash/actions/runs/43130587651/job/130893438856.
It checks the actual public producer and running browser, with two ordinary
assertion failures for the shared mapping and four passing controls.

Environment: unchanged Dash dev commit
b5a33c5b9191bef976e352b9feca14eaf93c9b7a, Dash 4.5.0, Python 3.12.16,
Node 24.22.2, Selenium 4.51.0, Chrome/ChromeDriver 157.0.8103.78, and Ubuntu
on a standard GitHub-hosted runner. The full npm run build completed first.

AI assistance was used to investigate and prepare this report. The observed
results above come from the linked native run.

主要言語
Python
スター
24.5k
フォーク
2.3k
平均マージ
3日 7時間
マージ済み PR(30日)
30

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/dash のほかの issue

plotly/dash の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。