Skip to content

fix(engine): refuse ProjectionType and StreamViewType outside their sets - #1110

Open
LeeroyHannigan wants to merge 12 commits into
mainfrom
fix/1051-projection-stream-enums
Open

LeeroyHannigan wants to merge 12 commits into
mainfrom
fix/1051-projection-stream-enums

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

CreateTable and UpdateTable now refuse a ProjectionType or a StreamViewType outside its set with DynamoDB's ValidationException text, where ExtendDB answered SerializationException. The message names each refused member at its path, for example 1 validation error detected: Value 'EVERY_ATTRIBUTE' at 'globalSecondaryIndexes.1.member.projection.projectionType' failed to satisfy constraint: Member must satisfy enum value set: [ALL, INCLUDE, KEYS_ONLY]. UpdateTable answers before the table lookup, so a refused request leaves an existing table without a stream.

EnumFaults (crates/engine/src/nested_enums.rs) records these members before ExtendDB reads the request. It puts the first value of the set in place of each refused value, so the read continues. A read error still answers first. A member of the wrong JSON type gets SerializationException, as on DynamoDB, and a KeyType outside its set gets the ValidationException of its reader (#1109). After the read, the record answers in DynamoDB's order: on CreateTable the GSIs, then streamViewType, then the LSIs, and on UpdateTable the Create entries, then streamViewType. It lists the first ten faults, and its count then says 10. extenddb_core::error::validation_errors writes the envelope. The constraint text moves out of validate_enum_fields into enum_constraint, which both callers use.

The typed read takes a structure written as a JSON array and an enum written as a JSON object (#1106). So when EnumFaults replaced a value, it refuses such a member itself with SerializationException, as DynamoDB does. The members are the structures, the lists of structures and the enums of a CreateTable or UpdateTable body, at any depth. A body with no refused value goes to the typed read as before, and the rest of #1106 stays with that issue.

UpdateTableInput now reads ReplicaUpdates as a list of JSON objects. A value that is not such a list, such as "x" or ["x"], fails the read and answers SerializationException ahead of the record, as on DynamoDB. ExtendDB accepts a list of objects and does not act on it, as before.

The BillingMode, TableThroughputMode, null StreamEnabled and table name checks keep their places.

The PartiQL request checks cap their faults at ten too, in MAX_PARTS. That module is behind the partiql feature, so nested_enums.rs has its own MAX_FAULTS.

The message of 454c768 says that "a member that the typed read refuses gets SerializationException". The KeyType reader refuses with a ValidationException of its own, as this section says. Whoever merges: please use the What section of this body as the squash message.

Why

These are DynamoDB's answers, measured in us-east-1. DynamoDB answered the rows of the issue on 13 and 14 November 2026. On 17 November 2026, 172 requests on these members went out twice each, with the same answer both times. ExtendDB at 454c768 gives DynamoDB's answer on 104 of them, and origin/main on 38. Each of the 172 requests that origin/main answered as DynamoDB keeps its answer. The only one of the 172 with ReplicaUpdates sends a string, which both element types refuse. On 25 November 2026, DynamoDB answered "ReplicaUpdates": ["x"] with SerializationException twice.

On 18 November 2026, six bodies had a refused enum value and a member of the wrong JSON type. DynamoDB answered each with SerializationException, twice (the comment on #1106). On 2 December 2026, five more UpdateTable bodies of that kind got SerializationException, twice each. On the same day, UpdateTable with twelve refused GSI Create entries got 10 validation errors detected and the first ten faults, twice.

Closes #1051

Testing done

  • At 8d1c0d2, cargo +1.97.0 test -p extenddb-engine passed 979 lib tests and 1 integration test. cargo +1.97.0 test -p extenddb-core passed 1245 tests, with 2 ignored, in its lib, integration and doc tests. cargo +1.97.0 test -p extenddb-wasm-adapter passed its 3 unit tests and the parity corpus test.
  • cargo +1.97.0 clippy --all-targets -- -D warnings on extenddb-core and extenddb-engine with --features extenddb-engine/backup-test-hooks is clean. So is the same command on the four storage crates with --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks, and cargo +1.94.0 check --all-targets on the core and the engine. The clippy step of the WebAssembly workflow is clean on this branch.
  • tests/test_table_enum_members.py sends the issue's rows and the rows with two refused members. It also sends the rows with a member of the wrong JSON type, with and without a refused value. It also sends the twelve GSI Create entries. After the refused UpdateTable of an existing table, the same UpdateTable with NEW_IMAGE enables one stream, which ListStreams reports. Against ExtendDB on SQLite, built from 8d1c0d2, this file passed 36 tests. The two Python suites collect with no error.
  • With the change reverted, the Rust row test fails on its first row. Three controls check the order of the record. When CreateTable records the stream view type ahead of the GSIs, the row test fails on the row with those two faults. When CreateTable records the LSIs first, it fails on the row with a GSI and an LSI. When CreateTable records the LSIs ahead of the stream view type, it fails on the row with an LSI and a stream view type. With the old ReplicaUpdates element type, it fails on the ["x"] row. With the production files of 0a3e466, it fails on the first row with a wrong JSON type beside a refused value. Without the cap of ten, it fails on the twelve Create entries.

Line counts: production +207 -6, tests +623 -1. The five lines that declare the row test module count as tests. The round of 2 December: production +97 -6, tests +149 -5. This round adds 9 lines to the upgrade manual.

Other open PRs:

Not in this PR, each with origin/main's answer: DynamoDB lists BillingMode, TableThroughputMode and a null StreamEnabled with these faults in one message. It answers a member of the wrong JSON type ahead of them, and a table name of a bad length first. #1109 lists those requests. A body with no refused value still reads a structure written as a JSON array or an enum written as a JSON object without error. DynamoDB answers SerializationException (#1106).

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a

Breaking changes

A client that sends CreateTable or UpdateTable with a ProjectionType or a StreamViewType outside its set gets ValidationException with DynamoDB's text, where it got SerializationException. An UpdateTable with a ReplicaUpdates value that is not a list of JSON objects gets SerializationException. The previous release did not read the member. The v1.2.0 entry of docs/manuals/07-upgrade-manual.md gives both changes.


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

CreateTable and UpdateTable answered a ProjectionType or StreamViewType
outside its set with SerializationException and the deserializer's text.
DynamoDB answers ValidationException with the enum text, the member path
and the set in its own order. On UpdateTable it answers before the table
lookup. Measured in us-east-1 on 13, 14 and 17 Nov 2026.

ExtendDB now records each such member before the read and gives it the
first value of its set. The read then goes on past it. Every read error
is still answered first, so a member that the typed read refuses gets
SerializationException, as on DynamoDB. Then ExtendDB refuses the
recorded members in one message, in DynamoDB's order.

The typed read takes a JSON array in place of a structure (#1106). A
body with such an array and a refused member gets the ValidationException,
where DynamoDB answers SerializationException.

UpdateTable now reads ReplicaUpdates as a list, so a value of another
type is refused with SerializationException, as on DynamoDB. A list is
still accepted and not acted on.

Fixes #1051.
Each row of the two row tables had one refused member. No test saw the
order of two recorded faults or the "2 validation errors detected"
envelope. Add the five two-fault rows measured on 17 Nov 2026. On
CreateTable the faults are in two GSIs, in a GSI and the stream view
type, and in a GSI and an LSI. On UpdateTable of a missing table they
are in a GSI Create and the stream view type, and in two GSI Creates.
Each row expects DynamoDB's text by equality.

The row test runs only with the partiql feature, which is on by
default. A comment on its module declaration now says so.
DynamoDB answers SerializationException to an UpdateTable whose
ReplicaUpdates list holds a string (measured 25 Nov 2026, us-east-1).
UpdateTableInput read each element as any JSON value, so ExtendDB
accepted the list and answered the "At least one of" text. Now it reads
each element as a JSON object, the element type that #1262 gives the
same member, and the read refuses the string.

@demohan demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProjectionType and StreamViewType outside their sets get the service's text, path and set order at e5301b0. With 158 rows sent twice to us-east-1 and to this head, main and this head merged into main on SQLite and PostgreSQL, every target answered alike both rounds and the backends agree on every row: lowercase, empty, unknown and trailing-space values and several faults at once match the service, wrong JSON types still answer SerializationException, the new ReplicaUpdates read refuses what the service refuses, and a refused UpdateTable on an existing table leaves no stream and no GSI. Tables main created with every ProjectionType and StreamViewType still describe, query, update and delete on the merged build. Nine of ten controls fail as they should, the Python test passes 21 of 21 here and fails 17 of 21 on main, and fmt, clippy, the 1.91.1 check and the tests are clean; the red wasm check is main's, since fixed. The branch now conflicts with main at 222d80a in partiql/test_context.rs:33; taking main's version as pub(crate) passes fmt, clippy, the 1.94.0 check, the wasm build and clippy, and the core and engine tests.

I will approve once a wrong-shape member beside a refused enum answers SerializationException as on main (here or by landing after #1106), the message lists at most ten faults, and a test holds the stream view type ahead of the LSIs.

let constraint = crate::enum_constraint(valid);
self.0.push((sent.to_owned(), path, constraint));
*value = Value::from(valid[0]);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing the refused value before the request is read lets the reader accept a JSON array where a structure belongs (#1106), so the wrong-shape member is no longer caught: on 10 shapes, such as a GSI ProjectionType all with Tags: [["k","v"]], KeySchema: [["pk","HASH"]] or SSESpecification: [true], and an UpdateTable stream view type x with ProvisionedThroughput: [1,1], the service and main answer SerializationException and this head the enum ValidationException. The body says so; fixing #1106 first, or reading the request before replacing the value, would keep main's answer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 87e5eaf, in crates/engine/src/nested_enums.rs. When EnumFaults replaces a refused value, it now refuses these members with SerializationException, as DynamoDB and main do:

  • a structure that is not a JSON object
  • an element of a list of structures that is not an object
  • an enum written as an object

A body with no refused value reads as before, and the rest of #1106 stays with that issue.

The rows hold the six bodies of the 18 Nov comment on #1106. They also hold two shapes from your list, KeySchema: [["pk","HASH"]] and SSESpecification: [true], beside a GSI ProjectionType of EVERY_ATTRIBUTE. Five more rows are UpdateTable bodies that DynamoDB answered with SerializationException on 2 Dec 2026, each twice. Beside a stream view type x the bodies carry ProvisionedThroughput: [1,1], SSESpecification: [true], BillingMode: {"PROVISIONED": null}, or a GSI Create with ProjectionType: {"ALL": null}. The fifth body has AttributeDefinitions: [["g","S"]] beside a GSI Create with ALL_ATTRIBUTES.

.iter()
.map(|(value, path, constraint)| (value.as_str(), path.as_str(), constraint.as_str()))
.collect();
let message = validation_errors(&faults);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 12 refused GSI ProjectionTypes, the service answers 10 validation errors detected and lists ten; this lists all twelve. The PartiQL checks already cap at ten. Separately, the service lists the stream view type ahead of the LSIs on a two-fault CreateTable too (LSI keys_only with stream new_image), not only on four-fault rows as the body says, and this head matches; with those two lines swapped the row test still passes, so a row for it would hold the order.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are in 9efe6a0, with the formatting in 8d1c0d2.

  • EnumFaults::check lists the first ten faults (MAX_FAULTS in crates/engine/src/nested_enums.rs). On 2 Dec 2026 DynamoDB answered twelve refused GSI Create entries with 10 validation errors detected and the first ten, twice. The row ut-twelve-gsi-creates and its Rust twin hold that answer. With the old check, the Rust row test fails on that row.
  • The row ct-lsi-stream sends your two-fault CreateTable, an LSI keys_only with a stream new_image, and expects the stream view type first. With the two lines of EnumFaults::create_table swapped, the Rust row test now fails on that row. The body's sentence about the four-fault rows is gone.

The PartiQL checks keep their cap in MAX_PARTS, in a module behind the partiql feature, so nested_enums.rs has its own MAX_FAULTS.

After EnumFaults replaces a refused ProjectionType or StreamViewType, the
typed read no longer stops at that value. It then takes a structure written
as a JSON array and an enum written as a JSON object (#1106). DynamoDB and
origin/main answer such a body with SerializationException.

When the record replaced a value, it now refuses these members with
SerializationException:

- a structure that is not a JSON object
- an element of a list of structures that is not an object
- an enum that is an object

A body with no refused value reads as before, and the rest of #1106 stays
open.

The rows hold the six bodies of the 18 Nov 2026 comment on #1106. They also
hold two CreateTable bodies of the same kind (measured 30 Nov 2026) and five
UpdateTable bodies (measured 2 Dec 2026).
DynamoDB lists the first ten faults of a refused body, and its count then
says 10. It answered so on 2 Dec 2026 to twelve refused GSI Creates.
EnumFaults listed all of them.

Also add a CreateTable row with an LSI fault and a stream view type fault.
DynamoDB lists the stream view type first.
cargo fmt wraps the rows that list ten faults and the row with an LSI fault
and a stream view type fault.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@demohan The replies in the two threads cover the three points of the review. The branch conflicted with main in crates/engine/src/partiql/test_context.rs. 0a3e466 merges main at 01556cf with git merge, and takes main's version of that file, with pub(crate) as main has it. The lines that this PR changes are the same before and after the merge. git merge-tree of the head 8d1c0d2 with main at c444cfc reports no conflict.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 8d1c0d2. 1 finding: 1 Docs.

The change makes CreateTable and UpdateTable answer a ValidationException for a ProjectionType or StreamViewType outside its set, records the faults before the typed read, lists at most ten, and reads ReplicaUpdates as a list of objects. Confirmed: of 21 requests sent to DynamoDB (us-east-1) and to this head on SQLite, a refused projection with duplicate index names, a refused view type with StreamEnabled false, a refused view type in UpdateTable on a missing table, and an enum or structure of the wrong JSON type beside a refused value returned the same status and exception type (and the same text for the first three). With the ten-fault cap, the wrong-type refusal or the list constants removed, refused_enum_members fails each time (12 faults listed instead of 10 at nested_enums_tests.rs:322; failures at :325). Engine (979 lib), the 36-test pytest file, and engine (981) plus core (1259) on the head merged with current main pass.

  • Docs docs/manuals/07-upgrade-manual.md:385 — The PR's own Breaking changes text is not in the upgrade manual's Behavior Changes by Release.

Docs — outside the diff

docs/manuals/07-upgrade-manual.md:385
Docs
The body lists two client-visible changes under Breaking changes: a refused ProjectionType/StreamViewType now answers ValidationException instead of SerializationException, and a non-list-of-objects ReplicaUpdates is refused. docs/manuals/07-upgrade-manual.md (section starting at line 385) has no entry, and the PR changes no file under docs/.

Fix: add one entry there with those two lines.

Evidence: git diff 01556cf..8d1c0d2 --stat -- docs prints nothing.

Main is at c8e66fb, six commits past 01556cf: #481, #1137, #1403,
#1465, #1515 and #1411. #1403 and #1411 add v1.2.0 entries at the top
of "Behavior Changes by Release" in docs/manuals/07-upgrade-manual.md,
where the entry of this branch goes next. The merge has no conflict.

Git merged crates/core/src/types/table.rs and crates/engine/src/lib.rs
at other lines. In table.rs, main changes the members of a DELETING
table in TableDescription, and this branch adds the ReplicaUpdates
member of UpdateTableInput. In lib.rs, main declares a test module, and
this branch declares nested_enums and adds enum_constraint. The lines
that this branch changes are the same before and after the merge.
Add a v1.2.0 entry at the top of "Behavior Changes by Release" in
docs/manuals/07-upgrade-manual.md, above the entries of main. It gives
the two changes that a client sees. A ProjectionType or StreamViewType
outside its set gets ValidationException in place of
SerializationException. UpdateTable refuses a ReplicaUpdates value that
is neither null nor a list of JSON objects.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base merges main at c8e66fb, which brings #481, #1137, #1403,
#1465, #1515 and #1411, and adds the v1.2.0 entry of #1110 to
docs/manuals/07-upgrade-manual.md. The merge has no conflict, and no
file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
Add a v1.2.0 entry at the top of "Behavior Changes by Release" in
docs/manuals/07-upgrade-manual.md, above the entry of #1110. It gives
the SSESpecification values that CreateTable now refuses and the
TableClass refusal of CreateTable and UpdateTable, with the texts of
DynamoDB. It also gives the read of an Enabled string.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base merges main at c8e66fb, which brings #481, #1137, #1403,
#1465, #1515 and #1411, and adds the v1.2.0 entries of #1110 and #1114
to docs/manuals/07-upgrade-manual.md. The merge has no conflict.

Git merged two files at other lines. In crates/core/src/types/table.rs,
main changes the members of a DELETING table in TableDescription, and
this branch changes the doc comment of the SSESpecification member of
UpdateTableInput. In crates/storage-mongodb/src/table_engine.rs, main
makes the creation time of a table description optional, and this
branch records the specification in update_table.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@LJMart11 Docs, docs/manuals/07-upgrade-manual.md:385: 936829a adds the entry "v1.2.0: a ProjectionType or StreamViewType outside its set gets ValidationException, and UpdateTable reads ReplicaUpdates" at the top of "Behavior Changes by Release". It gives the two changes of the Breaking changes section, each with the 1.1.0 answer, and what a rollback to 1.1.0 does. The entry names 1.2.0, because 1.1.0 shipped on 27 November 2026 without this change.

Before the entry, 4a91f04 merges main at c8e66fb with no conflict, so the entry sits above the v1.2.0 entries of #1411 and #1403.

Main is at c057660, one PR after the last merge of main into this
branch. #1446 added its v1.2.0 entry at the top of Behavior Changes by
Release in docs/manuals/07-upgrade-manual.md, where this branch had its
entry. The merge keeps main's entries in main's order and puts the entry
of this branch after main's v1.2.0 entries. Main adds each new entry at
the top, so the entry no longer conflicts with the next one.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked at 2792dee against the list from 8d1c0d2.

The follow-up merges main into the branch and adds the upgrade-manual entry for the new ValidationException answers. The head is the merge with the current base tip. On it, extenddb-core (1260 passed, 1 ignored) and extenddb-engine (982 passed) tests pass under 1.94.0, including nested_enums::tests::refused_enum_members. Replacing the wrong-JSON-type check in EnumFaults::member_types with a pass-through makes that test fail on a CreateTable row, so the guard is pinned. docs/manuals/07-upgrade-manual.md:419-426 now lists both client-visible changes.

Previous items: 3 fixed.

Main is at 5826e1b, three commits past c057660: #1531, #1466 and
#1087. In docs/manuals/07-upgrade-manual.md, #1531 adds a v1.2.0 entry
at the top of "Behavior Changes by Release", and git merged it with no
conflict. #1087 adds its v1.2.0 entry after the other v1.2.0 entries of
main, where this branch has its entry. That is the one conflict. The
merge keeps both entries without change: the entry of #1087 first, then
the entry of this branch, before the v1.1.0 entries. No other file has
changes on both sides.
@LJMart11

LJMart11 commented Dec 4, 2026

Copy link
Copy Markdown

Checked at 2792dee against the list from 8d1c0d2. The head moved again to 7dfc63b; this reviewer stops after two rounds and leaves the rest to a person.

Fixed:

  • item 3

Disputed: none.

Needs-human: none.

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

3 participants