gleanwork / gleanwork/api-client-python

Value model in AdditionalFieldDefinition is an empty class, thus silently drops all data

Đang mở
#133 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

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

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_fields
  • TeamInfoDefinition.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': [{}]}

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

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.

Đánh giá

Công nghệ
python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

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.