InMemoryBackingStore restores detached child values after replacement or clear
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with the InMemoryBackingStore implementation and its child-store subscription handling. The report identifies replacement, clear, list removal, and shared-child cases, and includes focused reproduction code plus validation results. Trace how subscriptions are added and removed, then run the abstractions suite; done when detached children cannot restore old values and current children remain tracked.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- Python 3.10.12, Linux
microsoft-kiota-abstractions1.18.0, also reproduced from currentmainat37b270459f391768df698142c741945365cd3191
Describe the bug
InMemoryBackingStore keeps subscriptions to nested models after their value is replaced or the store is cleared. A later edit to the detached model can restore the old object into the parent store. The replacement model is not subscribed when the property key already exists, so its edits do not mark the parent property changed after initialization is completed.
List replacement/removal has a related stale-subscription problem: removed items can mark their former parent property changed, and an item from a replaced list can restore the previous list.
To reproduce
from dataclasses import dataclass, field
from kiota_abstractions.store import BackedModel, InMemoryBackingStore
@dataclass
class Child(BackedModel):
backing_store: InMemoryBackingStore = field(default_factory=InMemoryBackingStore)
name: str = ''
store = InMemoryBackingStore()
old = Child(name='old')
current = Child(name='current')
store.set('child', old)
store.set('child', current)
store.is_initialization_completed = True
store.return_only_changed_values = True
current.name = 'current edited'
print('current child is tracked:', store.get('child') is current)
store.return_only_changed_values = False
old.name = 'detached edited'
print('detached child restored:', store.get('child') is old)
store.clear()
old.name = 'edited after clear'
print('clear remains empty:', store.enumerate_() == [])
Actual output on main:
current child is tracked: False
detached child restored: True
clear remains empty: False
Expected output:
current child is tracked: True
detached child restored: False
clear remains empty: True
The first result concerns the backing store's changed-value query, not an asserted HTTP serialization outcome. The second and third results also occur with return_only_changed_values=False.
Cause and candidate fix
The direct-model subscription is created only when the property key is absent, and its callback closes over the original model. List subscriptions have a stable parent/property ID, but subscriptions on removed child stores are never detached. clear() only clears the parent's values.
I have a local candidate that tracks child-store subscriptions per property, detaches obsolete subscriptions on replacement/clear, and checks the current value when a child notifies. It preserves subscriptions when a child is shared by two parents or by two keys.
Validation
- Unmodified main's abstractions suite: 264 passed.
- Added 18 focused cases: 16 fail on main and two pass as controls.
- Candidate: all 282 abstractions tests pass, including replacement by a model/scalar/None/list, clear, removed list items, shared children, and repeated assignments.
mypy kiota_abstractions: passes for all 48 source files; changed production file passes configured pylint with warnings and an existing unsupported configuration-option diagnostic disabled; yapf andgit diff --checkpass.- Linux/Python 3.10 only. The four existing date-utils deprecation warnings remain. No claim that other Python versions or the full monorepo suites were run.
This is separate from #802's duplicate list subscriptions and stale list-size fixes; those changes are already present on the tested main. I also checked #800 and #139. Would a focused PR covering subscription replacement and cleanup be welcome?
Investigation and candidate fix developed with AI assistance.
- Ngôn ngữ chính
- Python
- Star
- 31
- Fork
- 48
- Merge trung bình
- 16 giờ 36 phút
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/kiota-python
-
Backing store enumeration returns internal tracking tuples instead of stored listsCó thể đã có người làm @pradeep-ramola đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
microsoft/kiota-python#938 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JSON numeric getters accept booleans as integers and floatsCó thể đã có người làm @pradeep-ramola đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/kiota-python#935 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ensure 304 response code does not throwCó thể làm lại được @nightcityblade đã nhận 92 ngày trước và không có pull request nào đang mở. Đang mởhelp wanted type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/kiota-python#477 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
microsoft/kiota-python#898 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type:breaking-change
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
microsoft/kiota-python#777 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/kiota-python
Issue tương tự
-
backend: claude chore dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
briandconnelly/amicus#606 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
semantica-agi/semantica#2320 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
vllm-project/vllm-omni#11465 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
jxxghp/MoviePilot#7699 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
vllm-project/vllm-ascend#24010 ·
Maintainer thường phản hồi trong vòng 1 ngày