Repository navigation
fix(memory): queries refuse empty key values and start keys outside the key condition, and index keys have size limits - #133
Merged
kalaspuff merged 1 commit intoOct 31, 2026
Conversation
…he key condition, and index keys have size limits The in-memory backend returned nothing for key conditions with empty string or binary values, checked only the table key of a query's start key (index keys of another type or extra attributes restarted at the first item) and accepted start keys outside the key condition, all of which DynamoDB refuses. Secondary index key values had no size limit, and TransactWriteItems counted only Put items towards its 4 MB limit. Refs #93 Co-authored-by: Carl Oscar Aaro <[email protected]>
This was referenced Oct 31, 2026
fix(models): numbers of union fields render as stored, and literals of plain enum members write
#126
Merged
Contributor
Author
|
Stack of 10 pull requests, merged in this order with "Squash and merge":
|
This was referenced Oct 31, 2026
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
Requests DynamoDB refuses that the in-memory backend accepted, so tests passed where production fails (#93):
KeyConditionExpression:pk = :pwith:p = ""returned nothing. It now raises DynamoDB'sValidationException, "One or more parameter values are not valid. The AttributeValue for a key attribute cannot contain an empty string value. Key: pk" (reported against AWS in Dynamodb query with a KeyConditionExpression should raise ClientError when the partition key is empty getmoto/moto#7062), and thebinaryform forBkeys. This covers partition and sort key conditions, on tables and indexes.ExclusiveStartKeyof a query: only the table key was checked. An index start key with a number for a string key, or with an extra attribute, restarted at the first item, and start keys outside the key condition were accepted. The backend now follows what dynoxide-rs captured against DynamoDB (tests/query_start_key_and_key_conditions.rs):TransactWriteItemssize: onlyPutitems counted towards the 4 MB limit, so eleven updates that store 390 KB items each were accepted. Updates now count with the item they store.Verified with Rust tests of the memory backend for each rule, which fail without the fix.
make checkpasses, including the Python suites on the memory backend and MiniStack, whose cursors and pagination still fit.Refs #93: two size limits of the issue are left open, because no source gives DynamoDB's answer: the 400 KB limit on an item together with its local index entries, and a 4 MB limit for
TransactGetItems. I described them on the issue.Checklist
make checkpasses locally (lint, types, clippy, consistency, tests)Worth confirming
begins_withincluded, is refused like an empty partition key value. moto does so, and dynamoxy never sends an empty prefix itself.fctl session
Note
Low risk. It only changes the in-memory test backend, making it refuse requests that DynamoDB refuses, so tests that relied on the old leniency may start failing; production code against AWS is untouched.
What it does. Makes the in-memory DynamoDB reject queries with empty string or binary key values, reject
ExclusiveStartKeyvalues that are malformed or outside the key condition, and enforce the 2,048- and 1,024-byte size limits on secondary index keys.TransactWriteItemsnow also counts the stored size of updated items towards its 4 MB limit. The error messages follow what DynamoDB returns, as captured by dynoxide-rs.Stricter test backend. Application tests on the memory backend that used empty key values, hand-built start keys or oversized index keys will now fail with a
ValidationError, as they would against AWS.fctl review's first look at
5044d61· 5 files, +369 −22 · Review agent settings