Aiven-Open / Aiven-Open/karapace
Can't post to timestamp-milli fields using REST proxy.
- 主要語言
- Python
- 星號
- 634
- 分支
- 110
- 平均合併
- 4 天 7 小時
- 30 天內合併 PR
- 4
描述
# What happened?
```
POST to https://karapace/topics/mytopic
{
"key_schema": "{\"type\":\"string\"},
"value_schema": "{\"fields\":[{\"name\":\"updated\",\"type\":{\"logicalType\":\"timestamp-millis\",\"type\":\"long\"}}],\"name\":\"x\",\"type\":\"record\"}",
"records": [
{
"key": "14535018",
"value": {
"updated": 166445827700
}
}
]
}
```
gives the error
```
422 Unprocessable Entity
{
"error_code": 42205,
"message": "Object does not fit to stored schema"
}
```
# What did you expect to happen?
Message posted to topic.
# What else do we need to know?
The avro library expects a datetime.datetime for this type: https://github.com/apache/avro/blob/5a80e32e6bba7d44fef0edfe333ff62c55da1392/lang/py/avro/schema.py#L1012-L1013
Karapace uses json.loads to read the posted JSON data: https://github.com/aio-libs/aiohttp/blob/eb6b8636bb0fb1a3164e7f4aa6d55cae6309f822/aiohttp/typedefs.py#L18
json.loads only creates the object types here: https://docs.python.org/3/library/json.html#json-to-py-table
Reasonably it should probably be possible to use a JSON number here.
貢獻指南
評估
這個 Issue 還沒有評估資料。