Skip to content

fix(memory): type EventMetadataFilter.operator as str#551

Open
valter-silva-au wants to merge 1 commit into
aws:mainfrom
valter-silva-au:fix/event-metadata-filter-operator-type
Open

fix(memory): type EventMetadataFilter.operator as str#551
valter-silva-au wants to merge 1 commit into
aws:mainfrom
valter-silva-au:fix/event-metadata-filter-operator-type

Conversation

@valter-silva-au

Copy link
Copy Markdown

Summary

EventMetadataFilter.build_expression stores operator.value (the operator's string, e.g. "EQUALS_TO") in the returned dict, but the EventMetadataFilter TypedDict annotated operator as the OperatorType enum. Every constructed filter therefore mis-typed the field relative to the value that is actually serialized to the AgentCore service.

This annotates operator as str, matching the sibling MemoryMetadataFilter, which already documents and types the field this way.

Fixes #240

Changes

  • src/bedrock_agentcore/memory/models/filters.py: type EventMetadataFilter.operator as str (was OperatorType), with a clarifying comment mirroring MemoryMetadataFilter.
  • tests/.../models/test_filters.py: add the first unit tests for EventMetadataFilter — the field annotation plus build_expression for a value operator and an existence operator.

Testing

uv run pytest tests/bedrock_agentcore/memory/models/test_filters.py — all pass. No runtime behavior changes; build_expression already produced string operators.

`EventMetadataFilter.build_expression` stores `operator.value` (the
operator's string, e.g. "EQUALS_TO") in the returned dict, but the
TypedDict annotated `operator` as the `OperatorType` enum. Every
constructed filter therefore mis-typed the field, contradicting the
runtime value that is serialized to the AgentCore service.

Annotate `operator` as `str`, matching the sibling `MemoryMetadataFilter`
which already documents and types this the same way. Add the first unit
tests for `EventMetadataFilter` (the type previously had none), covering
the field annotation and `build_expression` for both a value operator
and an existence operator.

Fixes aws#240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type inconsistency in EventMetadataFilter TypedDict

1 participant