Decimal fields inside nested models aren't normalized in structured output
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #1181 của @Bndrwe — đã đóng, không merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
The recursion lives in normalize_decimal_fields in engine/processing/gsonschema/validators.py, which passes the root schema into nested dict and list values. Run the reproduction snippet against validate() in that file to see the nested price stay a string. Done means nested Decimal fields come back as rounded floats, same-name non-Decimal fields are untouched, and the existing tests in test_validators.py still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Priority Level
Medium (Annoying but has workaround)
Describe the bug
normalize_decimal_fields() (the #171 fix, in engine/processing/gsonschema/validators.py) only handles top-level fields. When it recurses into a nested dict or list it passes the root schema again instead of that field's own schema, so:
- Decimal fields in a nested model, a list of models, or an optional sub-model (
Item | None) keep whatever the LLM returned:"3.25"as a string, or7.257unrounded. - If a batch mixes both forms, the Parquet checkpoint write fails with
ArrowInvalid: Could not convert '3.25' with type str: tried to convert to double, the batch gets dropped, andcreate()ends with "Generated 0 of 4 requested records". Basically #171 again, one level down. - A nested field that shares a name with a top-level Decimal field gets the top-level rule, so a nested
code: strholding"2.25"comes back as the float2.3.
Steps/Code to reproduce bug
import json
from decimal import Decimal
from pydantic import BaseModel, Field
from data_designer.engine.processing.gsonschema.validators import validate
class LineItem(BaseModel):
name: str
price: Decimal = Field(decimal_places=2)
class Order(BaseModel):
total: Decimal = Field(decimal_places=2)
item: LineItem
items: list[LineItem]
schema = Order.model_json_schema()
data = {"total": "10.50", "item": {"name": "pen", "price": "3.25"}, "items": [{"name": "ink", "price": 7.25}]}
out = validate(data, schema, pruning=True, no_extra_properties=True)
print(json.dumps(out))
assert isinstance(out["item"]["price"], float), f"nested price stayed {out['item']['price']!r}"
On main (b802800): AssertionError: nested price stayed '3.25'. The top-level total is normalized to 10.5.
I also have a full preview() + create() repro with the LLM call patched out. That's where the Parquet write fails and 0 of 4 records come out. Happy to paste it.
Expected behavior
Nested Decimal fields get normalized the same way top-level ones do (float, rounded to decimal_places), and nested fields that aren't Decimal are left alone.
Agent Diagnostic / Prior Investigation
I used an agent to trace it. The recursion in normalize_decimal_fields calls normalize_decimal_fields(value, schema) with the root schema for both dict and list values, so nested lookups go against the root properties. A fix that carries the current sub-schema plus the root $defs (following local $ref, list items, and the object branch of anyOf for Model | None) makes the repro pass, and two new tests (nested/optional/list models, and the same-name string case) fail on main and pass with it. The existing 55 tests in test_validators.py still pass.
Searched issues/PRs for decimal, normalize_decimal_fields, nested Decimal: #171 and #182 are about top-level Decimal / the JSON-schema approach in general, #857/#858/#1046 touch nearby code but not this, and no open PR changes gsonschema/validators.py.
Additional context
Python 3.13, pandas 3.0.5, CPU only. I have the fix and tests on a branch and can open a PR once this is triaged.
Checklist
- I reproduced this issue or provided a minimal example
- I searched the docs/issues myself, or had my agent do so
- If I used an agent, I included its diagnostics above
- Ngôn ngữ chính
- Python
- Star
- 2.4k
- Fork
- 253
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
- 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 NVIDIA-NeMo/DataDesigner
-
Default OpenAI reasoning/vision model `gpt-5` is retired on 2026-12-11Có thể đã có người làm @pcbeingused333 đã nhận 23 ngày trước. Đang mởneeds-discussion triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
NVIDIA-NeMo/DataDesigner#1129 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Local seed path containing a single quote breaks the DuckDB queryCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
NVIDIA-NeMo/DataDesigner#1102 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enforce \from future import annotations` via ruff FA102 rule`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởtask
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA-NeMo/DataDesigner#760 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement needs-discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
NVIDIA-NeMo/DataDesigner#1180 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement needs-discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
NVIDIA-NeMo/DataDesigner#1179 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA-NeMo/DataDesigner
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Có thể đã có người làm @cestercian đã nhận hôm nay. Đang mởcomp/cli P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#162259 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[request] gRpc/1.86.0Đang mởupstream update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
conan-io/conan-center-index#31597 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
community-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA-NeMo/Run#727 ·
Maintainer thường phản hồi trong vòng 1 ngày