aws / aws/bedrock-agentcore-sdk-python

Type inconsistency in EventMetadataFilter TypedDict

Đang mở
#240 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
761
Fork
147
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
7

Mô tả

## Description

In `src/bedrock_agentcore/memory/models/filters.py`, the `EventMetadataFilter` TypedDict defines `operator: OperatorType` (an enum), but the actual value stored is a string.

```python
class EventMetadataFilter(TypedDict):
left: LeftExpression
operator: OperatorType # Type says enum
right: Optional[RightExpression]
```

The `build_expression` method correctly converts the enum to a string:
```python
filter = {"operator": operator.value} # Stores string, not enum
```

## Ramifications

1. **Type hint is misleading** - The TypedDict suggests `operator` holds an `OperatorType` enum, but it actually holds a string like `"EQUALS_TO"`

2. **Potential runtime error** - If a user follows the type hint and passes an enum directly (without using `build_expression`), boto3 will fail to serialize it since enums are not JSON serializable

3. **Type checker inconsistency** - Static type checkers like mypy may produce warnings or miss actual type errors due to this mismatch

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

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

Hướng nghiên cứu

Bắt đầu trong src/bedrock_agentcore/memory/models/filters.py bằng cách đọc EventMetadataFilter cùng với build_expression, hàm chuyển đổi toán tử trước khi lưu. Xác minh rằng annotation khớp với giá trị đã tuần tự hóa, sau đó chạy các bài kiểm tra Python liên quan và kiểm tra kiểu; được xem là hoàn tất khi TypedDict và biểu diễn lúc chạy khớp nhau mà không gây hiểu nhầm cho các bên gọi.

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
backend-api-design
Loại issue
Lỗi
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả 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.