Value model in AdditionalFieldDefinition is an empty class, thus silently drops all data
Chưa có ai nhận issue này.
Đá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
- 55/100
Hướng nghiên cứu
Bắt đầu trong glean/api_client/models/additionalfielddefinition.py bằng cách kiểm tra model Value đang trống và cách AdditionalFieldDefinition tạo danh sách value của nó. Tái hiện các ví dụ được ghi trong tài liệu với các đầu vào anchor, hyperlink và dictionary, sau đó xác nhận rằng model_dump() giữ nguyên dữ liệu đã cung cấp thay vì tạo ra các đối tượng trống.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The Value class in additionalfielddefinition.py is defined as an empty Pydantic BaseModel with no fields:
class Value(BaseModel):
r"""Either a string or HypertextField. When OpenAPI Generator supports oneOf, we can semantically enforce this in the docs."""
Because the SDK's BaseModel uses the default Pydantic extra = 'ignore' behavior, any data passed to Value(...) is silently discarded. This means the value field on AdditionalFieldDefinition, which is typed as Optional[List[Value]], cannot actually carry any data.
Impact
This affects any consumer using AdditionalFieldDefinition through either:
EmployeeInfoDefinition.additional_fieldsTeamInfoDefinition.additional_fields
When constructing an AdditionalFieldDefinition with values, the data in the value list is lost:
from glean.api_client.models.additionalfielddefinition import AdditionalFieldDefinition, Value
field = AdditionalFieldDefinition(
key="languages",
value=[Value(anchor="English"), Value(anchor="Spanish")]
)
print(field.model_dump())
# {'key': 'languages', 'value': [{}, {}]}
# ^^ ^^ all data silently dropped
The same applies to HypertextField-style values:
Value(anchor="Glean", hyperlink="https://glean.com")
# Value() — both anchor and hyperlink are silently ignored
This is the associated public docs page: https://developers.glean.com/api/indexing-api/bulk-index-employees. Note that even when passing in data to Value() as a dict, the whole dict object is ignored:
from glean.api_client.models.additionalfielddefinition import AdditionalFieldDefinition
raw = {"key": "username", "value": [{"username": "testuser"}]}
field = AdditionalFieldDefinition(**raw)
dumped = field.model_dump()
print(dumped)
# {'key': 'username', 'value': [{}]}
- Ngôn ngữ chính
- Python
- Star
- 20
- Fork
- 10
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 17
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 gleanwork/api-client-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
gleanwork/api-client-python#136 ·
-
Issue Obtaining Agent Schema Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
gleanwork/api-client-python#137 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
gleanwork/api-client-python#115 · 4 bình luận ·
-
Model serialization drops keys Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
gleanwork/api-client-python#105 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
gleanwork/api-client-python#57 · 2 bình luận ·
Tất cả issue của gleanwork/api-client-python
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100