Skip to content

fix(engine): answer a SearchVectors body without TopK as ValidationException - #1568

Open
navareamol wants to merge 2 commits into
mainfrom
fix/1461-searchvectors-missing-topk
Open

navareamol wants to merge 2 commits into
mainfrom
fix/1461-searchvectors-missing-topk

Conversation

@navareamol

Copy link
Copy Markdown
Collaborator

What

A SearchVectors body without TopK now answers ValidationException with the text missing field `TopK` . Before, it answered SerializationException with Start of structure or map found where not expected: missing field `TopK` .

The change is a small mapper, read_error, in crates/engine/src/search_vectors_request.rs. It applies only when the failed read says exactly missing field `TopK` . Every other read failure still goes through deserialize_error.

The message ends at the member name. The service adds at line 1 column N. A new row in docs/differences-from-dynamodb.md (Secondary Indexes section) records that difference. See the open question.

A body missing both TableName and TopK still answers SerializationException naming TableName, because serde reports the first missing member in declaration order. That case is unmeasured.

Why

Refs #1461.

The issue measured, on 24 Nov 2026 in us-east-1 with each request sent twice, that DynamoDB answers ValidationException missing field `TopK` at line 1 column 125. It gives the same answer for a table ARN in another account, ahead of the authorization decision. ExtendDB answered SerializationException.

The cause is in the code: SearchVectorsInput.top_k has no default (search_vectors_request.rs), so the read fails, and deserialize_error in crates/engine/src/lib.rs has no case for a missing field.

This is Refs and not Fixes because the answer still differs from the measured one by the position suffix.

Other paths and callers:

  • The server runs this check ahead of authorization once the table name passes check_table_name_chars (crates/server/src/handler.rs). The cross-account ARN case from the issue goes through the same check. It was not run end to end here.
  • handle_search_vectors calls the same check, so the engine entry point answers the same.
  • No other operation, PartiQL path, TTL, transaction, batch or storage backend reads this struct. The check runs before any storage call, so the answer does not depend on the backend.
  • No timing change: one string comparison on a path that already failed.

Open PR overlap: #1322 changes crates/engine/src/search_vectors.rs and crates/server/src/request_attributes.rs, not the files here. The two do not share lines, and I did not try merging them.

Testing done

Branch fix/1461-searchvectors-missing-topk, one commit on origin/main c057660. Run on the dev desktop, SQLite only (the test builds a SQLite catalog; the change is before any storage call). Mac and desktop trees match: 3f845df4b85cabdb14f0943eb1c9bcbe7d44eed7.

Check Command Result
format cargo fmt --check clean
clippy, default features cargo +1.97.0 clippy -p extenddb-engine --all-targets -- -D warnings clean
clippy, no default features same with --no-default-features fails on branch and on main with the same error: function memory_engine is never used in crates/engine/src/test_context.rs:17. Not caused by this change.
new test, 20 runs cargo test -q -p extenddb-engine --lib a_body_without_top_k 20 of 20 pass
module on branch cargo test -q -p extenddb-engine --lib search_vectors 64 passed, 0 failed
module on main same 63 passed, 0 failed (the 64th is the new test)

The crate has no test-hooks feature (its features are partiql, search-inequality-filters, backup-test-hooks), so that clippy variant does not apply. MSRV 1.88 build, the other backends, the Python wire tests and the whole workspace test run were not run.

Negative control. The tree was clean and committed. I replaced .map_err(read_error) with .map_err(crate::deserialize_error) in check:

--- a/crates/engine/src/search_vectors_request.rs
+++ b/crates/engine/src/search_vectors_request.rs
@@
-    let input = SearchVectorsInput::deserialize(body).map_err(read_error)?;
+    let input = SearchVectorsInput::deserialize(body).map_err(crate::deserialize_error)?;

Command: cargo test -q -p extenddb-engine --lib a_body_without_top_k. Result: 0 passed, 1 failed, with SerializationException("Start of structure or map found where not expected: missing field `TopK`"). After git checkout -- the status was empty.

Reproduce:

  1. Check out the branch on a host with Rust.
  2. Run cargo test -p extenddb-engine --lib a_body_without_top_k.

The test sends a body with every member except TopK against a table that does not exist, and expects ValidationException with the message missing field `TopK` .

Open question

  1. Position suffix. The service appends at line 1 column N, where the issue says N follows the body length (125 and 171). The check receives a parsed JSON value, so it has no position. A real column needs the raw body bytes passed through check_search_vectors_request, handle_search_vectors and the WebAssembly adapter. Re-serializing the value would give a column that can differ from the client's body. I left the suffix out. What exactly is the column of the body the service received, for example the byte offset after the closing brace? The issue does not give the two bodies, so I could not check 125 and 171.
  2. Check order with more than one fault. The issue measured a body that lacks only TopK. Not measured: TopK missing together with a SearchVector of the wrong length, with an IndexName shorter than 3 characters, or with a bad table name. On this branch, a body missing TopK answers the missing-member error first, because it fails at the read. A bad table name still answers first, because the handler runs this check only after check_table_name_chars passes (SearchVectors: table name checks answer in a different order and miss the length bounds #1462). A body missing TableName, IndexName or SearchVector is unchanged and still answers SerializationException; the issue lists these as not measured.

Amol Navare added 2 commits December 3, 2026 09:54
…ception

The service answers a SearchVectors request without TopK with a
ValidationException that reads "missing field `TopK`" followed by the
position in the body, measured on 2026-11-24 in us-east-1, each request twice.
ExtendDB mapped the failed read to a SerializationException.

The read of the body now answers the ValidationException for that one missing
member. The body reaches the check parsed, so the text ends at the member name
and leaves out the position. Other read failures keep their answer.

Refs #1461

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant