Skip to content

Query: the missing key refusal comes before the filter syntax and unused value checks when the key condition has an equality #712

Open

Description

@LeeroyHannigan

Measured on Amazon DynamoDB on 2026-10-31 between 23:04 and 23:06 UTC in us-east-1, each request twice with the same answer. The ExtendDB answers are from a SQLite server built from main at f49c5f823.

When a key condition misses an equality on a key attribute, the service reports an invalid FilterExpression and an unused value ahead of the key schema refusal. ExtendDB reports the key schema refusal first when the key condition has an equality clause on another attribute. #479 makes ExtendDB report the filter and unused value faults first for a key condition with no equality clause; the rows below have one.

Table with HASH pk and RANGE sk (both S), and a GSI with HASH g1 and g2 (both S) and no RANGE. :x and :y are S values.

Request Service ExtendDB
sk = :x Query condition missed key schema element: pk the same
sk = :x with an unused :y Value provided in ExpressionAttributeValues unused in expressions: keys: {:y} Query condition missed key schema element: pk
sk = :x with FilterExpression="nope(" Invalid FilterExpression: Syntax error; token: "<EOF>", near: "(" Query condition missed key schema element: pk
zz = :x with an unused :y the unused value sentence Query condition missed key schema element: pk
GSI, g1 = :x HASH key attributes g2 must have equality conditions specified in the query the same
GSI, g1 = :x with an unused :y the unused value sentence the HASH key attributes g2 sentence
GSI, g1 = :x with FilterExpression="nope(" the filter syntax error the HASH key attributes g2 sentence

handle_query (crates/engine/src/query.rs) classifies the key condition with resolve_key_schema_with and runs the single-attribute missing key check before it parses the FilterExpression and before the unused value check. The key value type check runs in the same block, and #544 moves it after the filter, projection, unused value and Select checks; the missing key and HASH equality refusals stay where they are.

The same position shows with #558's filter operator count: on the table above, pk = :p AND sk = :n with :n an N value and a FilterExpression of 301 operators answers Invalid FilterExpression: The expression contains too many operators; operator count: 301 on the service (measured 2026-10-31 23:10 UTC, twice) and the type sentence with #558, because the type check runs first.

Activity

  1. LeeroyHannigan commented on Nov 1, 2026

    @LeeroyHannigan
    CollaboratorAuthor

    The same position shows for an undefined #name in a key condition with an equality clause. Measured on Amazon DynamoDB on 2026-11-01 at 10:19 UTC in us-east-1, each request twice with the same answer, on a table with HASH pk and RANGE sk (both S), with no ExpressionAttributeNames: #p = :x and #p > :x both answer Invalid KeyConditionExpression: An expression attribute name used in the document path is not defined; attribute name: #p.

    By the code, main answers #p = :x with Query condition missed key schema element: pk: the single-attribute missing key check runs before the key condition's references are checked.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions