A number that is not finite is stored as None at a field that accepts None

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

Maintainer thường phản hồi trong vòng 1 ngày

@jeevanabhi-r đang làm issue này rồi.

Từ ngày 4/11/2026.

Đá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

Issue trỏ đến ess/spec/request_types.py, cụ thể là inline, và cho biết các bài kiểm thử xác thực yêu cầu đã được chuyển sang request_types_test.py. Trước tiên, hãy đọc inline và các bài kiểm thử liên quan, sau đó chạy tệp kiểm thử đó. Hoàn thành khi các số không hữu hạn bị từ chối nếu trường chấp nhận None, kể cả bên trong các nhóm và danh sách, đồng thời hành vi hợp lệ hiện có của None vẫn được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

A number that is not finite is refused at a float field, because JSON holds it as null. At a field that also accepts None, it is stored as None and the request is accepted, so the workflow runs with None instead of the value given.

import math
from pathlib import Path
from pydantic import BaseModel
from ess.spec.request_types import held

class P(BaseModel):
    stop: float | None = None

class Q(BaseModel):
    stop: float = 1.0

files = lambda name, marker: name
local_path = lambda ref: Path('x')
held(P, 'stop', math.inf, files, local_path)  # (None, []): accepted, stored as None
held(Q, 'stop', math.inf, files, local_path)  # ParamsError: stop: has no JSON form that reads back as the value

The same holds inside groups and lists, at any field whose type accepts None.

Cause: request_types.inline checks that the stored JSON form reads back as itself (stored vs the JSON form of again), not that it reads back as the value given (made). inf becomes null in stored, null validates as None, and None has the JSON form null again, so the check passes.

Found while moving the request-validation tests to request_types_test.py.

Ngôn ngữ chính
Python
Star
0
Fork
1
Merge trung bình
15 giờ 25 phút
Pull request đã merge (30 ngày)
60

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 scipp/essapps

Tất cả issue của scipp/essapps

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.