fix(memory): type EventMetadataFilter.operator as str#551
Open
valter-silva-au wants to merge 1 commit into
Open
fix(memory): type EventMetadataFilter.operator as str#551valter-silva-au wants to merge 1 commit into
valter-silva-au wants to merge 1 commit into
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EventMetadataFilter.build_expressionstoresoperator.value(the operator's string, e.g."EQUALS_TO") in the returned dict, but theEventMetadataFilterTypedDict annotatedoperatoras theOperatorTypeenum. Every constructed filter therefore mis-typed the field relative to the value that is actually serialized to the AgentCore service.This annotates
operatorasstr, matching the siblingMemoryMetadataFilter, which already documents and types the field this way.Fixes #240
Changes
src/bedrock_agentcore/memory/models/filters.py: typeEventMetadataFilter.operatorasstr(wasOperatorType), with a clarifying comment mirroringMemoryMetadataFilter.tests/.../models/test_filters.py: add the first unit tests forEventMetadataFilter— the field annotation plusbuild_expressionfor 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_expressionalready produced string operators.