BasicTypeMetaDataMixin.deserialize calls _init_meta on None.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc metadata.py và kiểm tra BasicTypeMetaDataMixin.deserialize, đặc biệt là cách hàm xử lý obj trước khi gọi _init_meta. Trước tiên, hãy tái hiện lỗi bằng ví dụ được cung cấp DateWithMeta.deserialize(None, ...). Công việc được xem là hoàn tất khi None được truyền cho trình xử lý và trường tùy chọn có thể để trống mà không gây ra AttributeError; hãy thêm hoặc chạy một bài kiểm thử hồi quy cho trường hợp này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
Steps to Reproduce:
- Define a Rune type with an optional basic-type field such as DateWithMeta
(cardinality 0..1). - Construct an instance via init without providing the optional field —
pydantic calls the field's WrapValidator with obj=None. - Observe the exception.
Expected Result:
None is returned via handler(None), allowing the optional field to remain
absent.
Actual Result:
AttributeError is raised:
"'NoneType' object has no attribute '_init_meta'"
Environment:
rune-python-runtime 2.2.2, pydantic 2.14.1, Python 3.11
Additional Context:
Observed when constructing NonNegativeQuantitySchedule via init; bypassed
in tests using model_construct() to skip validation.
metadata.py BasicTypeMetaDataMixin.deserialize leaves model=obj (None) when
obj is neither a base type nor a dict, then unconditionally calls
model._init_meta(allowed_meta) if meta checks are enabled.
Fix: add if obj is None: return handler(None) as the first check.
import datetime
import pytest
from rune.runtime.metadata import DateWithMeta
def test_r5_basic_type_deserialize_none_raises_attribute_error():
'''Calling DateWithMeta.deserialize(None, ...) raises AttributeError
because model is left as None before _init_meta is called.'''
with pytest.raises(AttributeError, match='_init_meta'):
DateWithMeta.deserialize(
None,
lambda x: x,
(datetime.date, str),
set(),
)
- Ngôn ngữ chính
- Python
- Star
- 0
- Fork
- 4
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 finos/rune-python-runtime
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
finos/rune-python-runtime#52 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
finos/rune-python-runtime#50 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
finos/rune-python-runtime#48 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
finos/rune-python-runtime#47 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
finos/rune-python-runtime#43 ·
Tất cả issue của finos/rune-python-runtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
AstrBotDevs/AstrBot#10720 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(xiaomi): curated picker list still offers six ids that return 400 (plan-limited vs retired)Đang mởcause/upstream comp/cli P2 provider/other tool/file type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#143900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
WLAN-Pi/wlanpi-profiler#341 ·
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 77/100
Maintainer thường phản hồi trong vòng 1 ngày