mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
* fix(dynamodb): reject undefined expression attribute placeholders PutItem/DeleteItem/UpdateItem ConditionExpression, UpdateItem's own UpdateExpression, Query KeyConditionExpression, Query/Scan FilterExpression, and TransactWriteItems' ConditionCheck/Put/Delete/Update ConditionExpression and Update UpdateExpression accepted a #name or :value placeholder with no matching ExpressionAttributeNames/Values entry, instead of rejecting it with AWS's ValidationException. Writes fell through to a false ConditionalCheckFailedException (or, inside a transaction, a TransactionCanceledException with a false ConditionalCheckFailed reason), reads silently evaluated the condition as non-matching (Query) or ignored it entirely (Scan), and an undefined #name in an UpdateExpression's SET clause was silently stored as an attribute literally named "#n" instead of being rejected (standalone UpdateItem and inside a transaction alike). An undefined #name in KeyConditionExpression additionally surfaced the wrong error, "Query condition missed key schema element", because attribute resolution silently left the alias unresolved. Generalizes the pattern already used for UpdateExpression's undefined :value check and Query's FilterExpression undefined #name check into a shared requireDefinedTokens helper, applied to the remaining expression/handler combinations, and built on the same ordered token scanner extractHashTokens and extractColonTokens already used. The helper reports whichever undefined token appears first in the text; in UpdateItem the ConditionExpression check now runs before the unused-EAN/EAV checks rather than after. ProjectionExpression's undefined #name check and KeyConditionExpression's undefined :value check were already correct and are untouched. * fix(dynamodb): check undefined placeholders before semantic validation ExpressionEvaluator.validateExpression's semantic checks (contains()'s distinct-operand rule, begins_with()'s operand type, BETWEEN's bound ordering) ran before requireDefinedTokens at every call site, so an undefined #name/:value could surface the wrong error, e.g. contains(#missing, #missing) reported the distinct-operand error instead of the undefined name. Verified against amazon/dynamodb-local:3.3.1 that DynamoDB reports the undefined placeholder first for contains(), begins_with() type mismatch, and BETWEEN bound ordering, while a syntax error or redundant parentheses still outrank an undefined placeholder. Splits validateExpression into validateSyntax (tokenize/parse/redundant- parentheses, unchanged position) and validateSemantics (the checks above), and reorders each handler to run requireDefinedTokens between them. validateExpression itself is untouched and still used as-is by DynamoDbVectorSearch's SearchConditionExpression. In UpdateItem, ConditionExpression's semantic check must also outrank the unused-EAN/EAV checks (#2893), not just requireDefinedTokens: moved validateSemantics to run immediately after requireDefinedTokens(conditionExpression) in both the UpdateExpression-present and UpdateExpression-absent branches, ahead of checkUnusedEan/checkUnusedEav. Verified the same ordering already held in PutItem, DeleteItem, Query and Scan (their unused checks already ran after validateSemantics), and that TransactWriteItems has no unused-EAN/EAV check to conflict with. Also adds braces to the unbraced conditionals in the token scanner added by the previous commit, per AGENTS.md. * fix(dynamodb): keep projection validation after filter semantics The syntax/semantics split moved FilterExpression's undefined-token and semantic checks below ProjectionExpression's in Query and Scan, so a Query/Scan with FilterExpression "contains(a, a)" and an undefined #name in ProjectionExpression now reports the projection error instead of the filter one. Verified against amazon/dynamodb-local:3.3.1: FilterExpression's checks outrank ProjectionExpression's, which in turn outrank KeyConditionExpression's (unchanged, and already correctly ordered).