Repository navigation
fix(server): count a table name in UTF-16 code units in four operations - #1130
LeeroyHannigan wants to merge 5 commits into
Conversation
CreateTable, DescribeTable, DeleteTable and UpdateTable refuse a TableName outside the name pattern with the pattern clause. When the name is also too short or too long, they add a length clause. The server counted the name in characters when it chose that clause. DynamoDB counts it in UTF-16 code units on these four operations. Two emoji are 4 code units, so DynamoDB adds no too-short clause. A name of 128 emoji is 256 code units, so DynamoDB adds the too-long clause. A name of 200 U+00E9 (200 code units, 400 bytes) gets no length clause. The server now counts the name in UTF-16 code units for these four operations. The item operations and ListTables keep the character count, as DynamoDB counts characters there. Measured in us-east-1 on 14 and 18 Nov 2026. Fixes #1019.
The base branch now merges main at e96a60f and adds three commits of #1127. No file conflicted. In crates/core/src/validation/table_name_length.rs, table_name_bounds from the base sits after count_clause from this branch. In crates/server/src/table_name_gate.rs, the new comment of check_transact_items from the base sits beside the utf16 argument of this branch. The README.md table of checks gets the change of this branch too. Its table names row now says that the server counts the name in UTF-16 code units on CreateTable, DescribeTable, DeleteTable and UpdateTable. The other operations count it in characters.
The comment of UTF16_LENGTH said that the item operations count characters. The requests of 18 Nov 2026 show the character count on GetItem and PutItem with their Key or Item, and on Query, Scan and TransactWriteItems. The requests of 25 Nov 2026 show it on ListTables. DeleteItem and UpdateItem went out only without their Key, and DynamoDB answered the null member first. BatchGetItem and BatchWriteItem are not in these requests. The comment now names the measured operations.
four_operations_count_a_name_in_utf16_code_units now also sends two names on the bounds to CreateTable, DescribeTable, DeleteTable and UpdateTable. These are U+1F600 followed by "a" (3 code units) and 127 U+1F600 followed by "a" (255 code units). On 18 Nov 2026 DynamoDB answered both with the pattern clause alone on the four operations. With a count of one code unit more than the name has, the test now fails at the second name.
test_utf16_code_units accepted the two clauses in either order. DynamoDB listed the length clause first in every recorded send of 128 U+1F600 to these four operations. That was 8 of 8 sends on 18 Nov 2026 and 6 of 6 on 25 Nov 2026. The test now asserts that order by equality, as test_describe_table does.
demohan
left a comment
There was a problem hiding this comment.
The four operations count a table name in UTF-16 code units at 539e484, as the service does. On all 40 pairs of those operations and ten names around the 3 and 255 unit bounds, sent twice to us-east-1 and to this head on SQLite and PostgreSQL, the status, error type and message match the service, and 200 é (400 bytes) gets the pattern clause alone there as here; the other 20 operations answer as on the base. No name moves between accepted and refused on any operation, since every name inside the pattern is ASCII: a 255-character name was created and used by 16 operations here and live, and 256 is refused by both. Seven negative controls fail as they should, the wire test fails 8 of 12 on the base and passes 12 of 12 here on both backends, fmt, both clippy commands, the lib tests and the 1.91.1 check are clean. Onto main at 222d80a it conflicts only in partiql/test_context.rs, as #1127 does alone; resolved, the tree builds and passes. Nothing on main fixes #1019 already.
| } | ||
| if outside { | ||
| return Err(bare_names_error(&names)); | ||
| return Err(bare_names_error(&names, false)); |
There was a problem hiding this comment.
Optional. Counting code units for the TransactWriteItems list here, or for the name members at line 237 (ListTables, both restores, ImportTable), still passes 15 of 15 tests, though the service counts characters on both. Rows with 128 😀 for TransactWriteItems and ListTables would hold them. The label at line 891 uses the character count, so the 255- and 256-unit rows both read CreateTable 128 characters, and the module doc at table_name_length.rs:15 names only length_clause though the gate now also uses count_clause. The wire test lacks the two bound names (😀a, and 127 😀 with a) the Rust test has.
Changes since the last review
The branch now merges the new head of #1127, which merges main at e96a60f. Four commits follow the head 9659d57:
fix/1056-table-name-lengthat a883891. In README.md, the table names row now says that the server counts UTF-16 code units on CreateTable, DescribeTable, DeleteTable and UpdateTable. On the other operations it counts characters.UTF16_LENGTH, the operations where the measurements show a character count. The comment said "the item operations".😀a(3 code units) and 127😀followed bya(255 code units).The body now gives the test counts of the final head and names one new issue.
What
CreateTable, DescribeTable, DeleteTable and UpdateTable refuse a
TableNameoutside the name pattern with the pattern clause. When the name is also shorter than 3 or longer than 255, they add a length clause. The server's table name gate now counts the name in UTF-16 code units for these four operations when it chooses that clause, as DynamoDB does. Before this change it counted characters, so an emoji counted once where DynamoDB counts it twice.For example,
😀😀(2 characters, 4 code units) now gets the pattern clause alone. A name of 128😀(256 code units) now getsMember must have length less than or equal to 255beside the pattern clause.The other operations of the gate keep the character count. DynamoDB counts characters on GetItem and PutItem with their
KeyorItem, and on Query, Scan, TransactWriteItems and ListTables.count_clause(count, bounds)inextenddb_core::validation::table_name_lengthis now the one place that maps a count to a clause, andlength_clausecalls it with the character count. The gate'sUTF16_LENGTHlists the four operations.check_namepassesutf16tobare_names_errorfor them, and every other caller passesfalse.The table of checks in README.md says which operations count UTF-16 code units.
This PR targets the branch of #1127,
fix/1056-table-name-length, because it extends thelength_clausethat #1127 adds. Merge #1127 first.Why
These are DynamoDB's answers, measured in us-east-1. The issue's rows date from 14 November 2026. On 18 November 2026, more requests went to the four operations, and each one went out twice with the same answer both times:
é(200 code units, 400 bytes) and 128éget the pattern clause alone. So DynamoDB counts UTF-16 code units, not UTF-8 bytes.😀a(2 characters, 3 code units) gets no too-short clause.😀followed bya(255 code units) gets no too-long clause.Closes #1019
The message of the first commit says that "the item operations" keep the character count, and the measurements cover only some of them. Please use What as the squash message.
Not in this PR
Each of these is in an open issue:
ItemorKeygets the null member from DynamoDB, where ExtendDB answers the name (An absent or null TableName answers SerializationException in UpdateTable, DescribeTable, DeleteTable, GetItem, Query and Scan, where DynamoDB answers ValidationException #1108).Conflicts with other open PRs
git merge-treeof this branch at 539e484 ran against each open PR that changes one of its files. It finds no conflict that the branch of #1127 at a883891 does not have too. The body of #1127 lists those conflicts.Testing done
At 539e484:
cargo test -p extenddb-core --lib: 1177 passed, 1 ignored.cargo test -p extenddb-engine --lib: 892 passed.cargo test -p extenddb-server --lib: 516 passed, 5 failed. The 5 arebackup_store::testsprivacy tests. They fail on the build host because of the ownership of/local/home, without this change too.cargo test -p extenddb-wasm-adapter: 3 unit tests and the parity corpus test pass.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine -p extenddb-server --all-targets -- -D warnings, the same command with--features extenddb-engine/backup-test-hooks, andcargo fmt --all -- --checkare clean.cargo +1.91.1 check -p extenddb-core -p extenddb-engine -p extenddb-server --all-targetspasses..github/workflows/wasm.ymlis clean on this branch with the one-line change of fix(core): read the latency segment clock through web_time #1482 applied. Main fails that step since fix(metrics): bound latency segment memory by summing into fixed time buckets #398, and fix(core): read the latency segment clock through web_time #1482 fixes it.four_operations_count_a_name_in_utf16_code_unitssends the issue's two names, the two names on the bounds and 200éto the four operations. It sends 128😀to Query and Scan. With the fix reverted, it fails atCreateTable 2 characters. With a count of one code unit more than the name has, it fails atCreateTable 128 characters, the name of 127😀followed bya.tests/python/test_nul_table_name_fields.py,tests/python/test_nul_table_names.py,tests/python/test_nul_arn_shapes.pyandtests/test_table_operations.pypassed 139 tests.TestSeveralConstraintsAtOnce::test_utf16_code_unitsasserts the length clause first, by equality. DynamoDB listed the length clause first in every recorded send of 128😀to the four operations. That was 8 of 8 sends on 18 November 2026 and 6 of 6 on 25 November 2026.😀😀, 128😀and😀a, 57 requests in all. ExtendDB answered each one as the base 8f8ecca does.Line counts against the branch of #1127: production +36 -10, tests +84, docs +1 -1.
Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, 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, DescribeTable, DeleteTable or UpdateTable with a
TableNameoutside the pattern can get another length clause than the previous release gave. A character above U+FFFF counts twice now, so😀😀gets the pattern clause alone and 128😀gets the too-long clause beside it.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.