aws / aws/bedrock-agentcore-sdk-python
Type inconsistency in EventMetadataFilter TypedDict
- Dominant language
- Python
- Stars
- 761
- Forks
- 147
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 7
Description
## 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
Contributor guide
Assessment
This issue has not been assessed yet.