Repository navigation
fix(expressions): contains() encodes members of lists and sets as the field stores them - #116
Merged
kalaspuff merged 1 commit intoOct 31, 2026
Conversation
… field stores them FieldPath.contains built a Path whose encoder was the element codec, and Path.contains took that codec's element() again, which is None for datetimes, dates, UUIDs, timedeltas, plain enums and documents. The value went into the expression unencoded, and every request with it failed with "cannot store a value of type datetime" before any I/O. contains() now validates and encodes the value with the element codec, as comparisons do with the field's codec. Fixes #112 Co-authored-by: Carl Oscar Aaro <[email protected]>
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.
What and why
contains()on a model field that holds a list or set of values with a codec (list[datetime],list[date],set[UUID],list[timedelta], a list of plainEnummembers or of documents) put the Python value into the expression unencoded, so every filter or condition with it raisedValidationError: cannot store a value of type datetime in DynamoDBbefore any request.FieldPath.containsbuilt aPathwhose encoder was the element codec, andPath.containsthen took that codec'selement()again, which isNonefor these types. Lists and sets of strings, numbers and bytes only worked because their values need no encoding.contains()now validates and encodes the value with the element codec, the way comparisons use the field's codec, so a value of the wrong type raisesValidationErrornaming the field when the condition is built. Fields without elements (strings, bytes, JSON) still take a substring as given. The usage guide says so.Verified with an integration test on the in-memory backend and MiniStack that filters on lists and sets of datetimes, dates, UUIDs, timedeltas, plain enums, documents and strings, a substring, and an update condition, and that fails without the fix; and a unit test of the encoded value for a pydantic model.
make checkpasses.Fixes #112
Checklist
AGENT_GUIDE.md, changelog)make checkpasses locally (lint, types, clippy, consistency, tests; no Rust change)fctl session
Note
Low risk. It changes how
contains()builds its condition for list and set model fields, in one method of the Python expression layer, and it was failing outright for the affected element types before.What it does.
contains()on a model field holding a list or set of values with a codec (datetimes, dates, UUIDs, timedeltas, plain enums, documents) now validates and encodes the value with the element codec, so filters and conditions on those fields no longer raiseValidationErrorbefore any request. Fields without elements (strings, bytes) still take a substring as given. Tests cover the in-memory backend, MiniStack and a pydantic model, and the usage guide and changelog are updated.Stricter checks. A value of the wrong type passed to
contains()on a list or set field, such as astrfor alist[int], now raisesValidationErrornaming the field when the condition is built, where it used to be sent unchecked.fctl review's first look at
93c980d· 5 files, +97 −9 · Review agent settings