apache / apache/pulsar-client-python
[Bug] Nested arrays decoding not working as expected
- 主要語言
- Python
- 星號
- 75
- 分支
- 53
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### Version
OS: Ubuntu 22.04
Python: 3.10.2
Pulsar: pulsar-client==3.2.0
### Minimal reproduce step
```python3
from pulsar.schema import JsonSchema, Record, Array, String
class A(Record):
a = String()
class B(Record):
b = Array(Array(A()))
# Decode JSON data
json_data = '{"b": [[{"a": "hello world"}]]}'
decoded_data = JsonSchema(B).decode(json_data)
# Access the nested objects
nested_objects = decoded_data.b[0][0]
print(type(nested_objects))
print(nested_objects.a)
```
### What did you expect to see?
```
<__main__.A object at 0x7fd1ecd07d00>
hello world
```
### What did you see instead?
```
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'dict' object has no attribute 'a'
```
貢獻指南
研究方向
先使用 JsonSchema(B).decode 執行 Python 重現程式,並檢查巢狀的 Array 值如何解碼。追蹤 JsonSchema.decode 進入點,並新增涵蓋 Array(Array(A())); 的迴歸測試;當內部值是其 a 屬性設為 "hello world" 的 A 物件時,即完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100