gleanwork / gleanwork/api-client-python
Value model in AdditionalFieldDefinition is an empty class, thus silently drops all data
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 20
- 派生
- 10
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 17
描述
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': [{}]}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从检查 glean/api_client/models/additionalfielddefinition.py 中空的 Value 模型,以及 AdditionalFieldDefinition 如何构造其 value 列表开始。使用 anchor、hyperlink 和 dictionary 输入重现文档中的示例,然后确认 model_dump() 会保留所提供的数据,而不是生成空对象。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100