aws / aws/bedrock-agentcore-sdk-python
Type inconsistency in EventMetadataFilter TypedDict
- Lingua principale
- Python
- Stelle
- 761
- Fork
- 147
- Merge medio
- 1g 23h
- PR unite (30g)
- 7
Descrizione
## 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in src/bedrock_agentcore/memory/models/filters.py leggendo EventMetadataFilter insieme a build_expression, che converte l’operatore prima di memorizzarlo. Verifica che l’annotazione corrisponda al valore serializzato, quindi esegui i test Python pertinenti e i controlli dei tipi; il lavoro è completato quando TypedDict e la rappresentazione a runtime concordano senza indurre in errore i chiamanti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend-api-design
- Tipo di issue
- Bug
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 55/100