aws / aws/bedrock-agentcore-sdk-python
Type inconsistency in EventMetadataFilter TypedDict
- Dominant language
- Python
- Stars
- 764
- Forks
- 148
- 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
Research direction
Start in src/bedrock_agentcore/memory/models/filters.py by reading EventMetadataFilter alongside build_expression, which converts the operator before storing it. Verify the annotation matches the serialized value, then run the relevant Python tests and type checks; done means the TypedDict and runtime representation agree without misleading callers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100