adapter.json, adapter.xml: Falsy Extension and Qualifier values omitted
Maintainer thường phản hồi trong vòng 1 ngày
@LivingLikeKrillin đang làm issue này rồi.
Từ ngày 30/10/2026.
- #683 của @LivingLikeKrillin — đang mở
Đá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
- 85/100
Hướng nghiên cứu
Đọc sdk/basyx/aas/adapter/json/json_serialization.py và sdk/basyx/aas/adapter/xml/xml_serialization.py, tập trung vào _qualifier_to_json, _extension_to_json, qualifier_to_xml và extension_to_xml. Đổi guard if obj.value: thành if obj.value is not None: trong mỗi file, mirroring Property serialization. Thêm các test round-trip cho 0, Decimal("0") và False trong cả hai adapter; done nghĩa là các giá trị falsy sống sót qua serialize-deserialize.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
In both adapter.json and adapter.xml, when an Extension or Qualifier has a value that evaluates to falsy in Python—such as integer 0, Decimal("0"), or False—the serializers omit the value field or attribute entirely. Non-falsy values (such as 1) are serialized as expected.
This was discovered while validating AAS JSON environments generated by an external tool, where an Extension with an xs:decimal value of "0" lost its value after being re-serialized by BaSyx.
This behavior was observed in basyx-python-sdk 2.1.0 (from PyPI) and verified on the current develop branch.
Expected vs. Actual Behaviour
- Expected: Falsy values such as
0,Decimal("0"), andFalseare preserved in the serialized output. - Actual: The
valueis omitted from the serialized JSON/XML. During a round trip (serialize and then deserialize), the value becomesNone, resulting in data loss. The deserializers already parse"0"correctly if the value is present.
Technical Details & Root Cause
In sdk/basyx/aas/adapter/json/json_serialization.py:
_qualifier_to_jsonand_extension_to_jsonguard the value usingif obj.value:.
In sdk/basyx/aas/adapter/xml/xml_serialization.py:
qualifier_to_xmlandextension_to_xmlguard the value usingif obj.value:.
Because 0, Decimal("0"), and False evaluate to False in Python boolean evaluation, the value is not written. For comparison, Property serialization already uses if obj.value is not None:.
Reproduction
import io, json
from basyx.aas import model
from basyx.aas.adapter import json as aas_json
sm = model.Submodel(
"https://example.org/sm",
extension=[model.Extension("e", value_type=model.datatypes.Int, value=0)],
qualifier=[model.Qualifier("q", value_type=model.datatypes.Int, value=0)],
)
buf = io.StringIO()
aas_json.write_aas_json_file(buf, model.DictIdentifiableStore([sm]))
print(json.loads(buf.getvalue())["submodels"][0]["extensions"])
# [{'valueType': 'xs:int', 'name': 'e'}] -- no "value"
The qualifier output also lacks the "value" field. The XML adapter exhibits the same behavior.
Suggested Fix
Update _qualifier_to_json, _extension_to_json, qualifier_to_xml, and extension_to_xml to check if obj.value is not None:, matching the implementation in Property.
A pull request containing this fix alongside round-trip tests for 0, Decimal("0"), and False in both adapters will be submitted and reference this issue.
- Ngôn ngữ chính
- Python
- Star
- 107
- Fork
- 61
- Merge trung bình
- 1 giờ 9 phút
- Pull request đã merge (30 ngày)
- 2
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 eclipse-basyx/basyx-python-sdk
-
server: XML responses contain `cursor="None"` on the last pageCó thể đã có người làm @qiaobochi040726-source đã nhận 14 ngày trước. Đang mởbug good-first-issue server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
eclipse-basyx/basyx-python-sdk#673 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
adapter.aasx: Failsafe writer adds duplicate parts for conflicting filesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug good-first-issue sdk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
eclipse-basyx/basyx-python-sdk#671 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good-first-issue server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
eclipse-basyx/basyx-python-sdk#670 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
adapter.aasx: Missing supplementary file aborts reading with failsafeCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug good-first-issue sdk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
eclipse-basyx/basyx-python-sdk#665 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
eclipse-basyx/basyx-python-sdk#663 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của eclipse-basyx/basyx-python-sdk
Issue tương tự
-
docs size:S
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
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 74/100
strawberry-graphql/strawberry#4794 ·
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 78/100
dataforgoodfr/cetolog#21 ·
-
security_citations_test fails against ecc 2026.11.6: SECURITY.md quotes ecc v2026.11.2's linesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
btclib-org/btclib#2932 ·
Maintainer thường phản hồi trong vòng 1 ngày