Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

BasicTypeMetaDataMixin.deserialize calls _init_meta on None.

Đang mở Phù hợp với người mới
#51 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

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:
  1. Define a Rune type with an optional basic-type field such as DateWithMeta
    (cardinality 0..1).
  2. Construct an instance via init without providing the optional field —
    pydantic calls the field's WrapValidator with obj=None.
  3. 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của finos/rune-python-runtime

Tất cả issue của finos/rune-python-runtime

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.