Query KeyConditions with a malformed N value gets HTTP 200, where DynamoDB answers The parameter cannot be converted to a numeric value

Aperta Adatta ai principianti
#1,252 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, sqlite

Direzione di ricerca

Inizia con desugar_key_conditions in crates/engine/src/legacy_filter.rs e handle_query in crates/engine/src/query.rs, poi leggi validate_and_normalize_number in crates/core/src/validation/number.rs e il controllo del valore dell’espressione nella PR #544. Aggiungi il controllo numerico per i valori N in Legacy KeyConditions prima dell’archiviazione. Il lavoro è completo quando i valori N malformati e vuoti restituiscono HTTP 400 con il testo di errore di DynamoDB, mentre un valore N valido continua a restituire HTTP 200; copri questi casi nei test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Query on a KEYS_ONLY GSI ngsi with HASH n (N), with the legacy KeyConditions {"n": {"ComparisonOperator": "EQ", "AttributeValueList": [{"N": "abc"}]}}, gets HTTP 200 with Count 0 from ExtendDB. The same request with an empty number, {"N": ""}, gets the same answer.

Amazon DynamoDB answers both requests with HTTP 400 ValidationException:

Value DynamoDB
{"N": "abc"} The parameter cannot be converted to a numeric value: abc
{"N": ""} The parameter cannot be converted to a numeric value: (the text ends in a colon and a space)

With {"N": "1"} both answer HTTP 200 with Count 0. The table has HASH pk and RANGE sk, both S, and holds no items.

The expression form gets the same answers: n = :v with :v set to {"N": "abc"} or {"N": ""} gets HTTP 200 from ExtendDB and the texts above from DynamoDB. #618 lists Query expression values among the values that get no number check, and open PR #544 adds that check for ExpressionAttributeValues.

Measured in us-east-1 on 20 Nov 2026 with signed requests from the AWS SDK for Python, with its parameter validation and retries off. Each request went out twice and got the same answer both times. The ExtendDB answers come from the v1.0.0 release binary on SQLite (npm @extenddb/linux-x64 1.0.0, commit c2e9a32b0), measured the same day with the same requests, twice. origin/main at 2ef56139e changes none of the files named below since v1.0.0.

desugar_key_conditions in crates/engine/src/legacy_filter.rs copies each AttributeValueList value into the key condition's value map as written. In handle_query (crates/engine/src/query.rs), check_key_value_type compares the type descriptor with the key schema and does not read the number. No call to validate_and_normalize_number (crates/core/src/validation/number.rs) reads these values before storage, so the SQLite backend looks up the text abc and finds no row.

Not measured: a RANGE key entry, the other operators, and PostgreSQL, MongoDB and Cassandra. #618 records HTTP 500 for a BatchWriteItem that writes an N sort key abc. I did not check whether this Query answers 200 on the other backends.

Proposed change: check each N value of KeyConditions with the number rules before storage, and answer the texts above. The check for ExpressionAttributeValues in #544 gives the expression form the same answers. The empty value needs the colon and the space that #960 asks for.

Lingua principale
Rust
Stelle
517
Fork
60
Merge medio
4g 23h
PR unite (30g)
134

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ExtendDB/extenddb

Tutte le issue di ExtendDB/extenddb

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.