Skip to content

fix(server): count a table name in UTF-16 code units in four operations - #1130

Open
LeeroyHannigan wants to merge 5 commits into
fix/1056-table-name-lengthfrom
fix/1019-utf16-table-name
Open

LeeroyHannigan wants to merge 5 commits into
fix/1056-table-name-lengthfrom
fix/1019-utf16-table-name

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • c9c2f3d merges fix/1056-table-name-length at 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.
  • f8e902c names, in the comment of UTF16_LENGTH, the operations where the measurements show a character count. The comment said "the item operations".
  • d9c86dc adds the two measured names on the bounds to the gate test, 😀a (3 code units) and 127 😀 followed by a (255 code units).
  • 539e484 makes the wire test assert the measured clause order, the length clause first, by equality.

The body now gives the test counts of the final head and names one new issue.

What

CreateTable, DescribeTable, DeleteTable and UpdateTable refuse a TableName outside 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 gets Member must have length less than or equal to 255 beside the pattern clause.

The other operations of the gate keep the character count. DynamoDB counts characters on GetItem and PutItem with their Key or Item, and on Query, Scan, TransactWriteItems and ListTables.

count_clause(count, bounds) in extenddb_core::validation::table_name_length is now the one place that maps a count to a clause, and length_clause calls it with the character count. The gate's UTF16_LENGTH lists the four operations. check_name passes utf16 to bare_names_error for them, and every other caller passes false.

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 the length_clause that #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 é (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.
  • 127 😀 followed by a (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:

Conflicts with other open PRs

git merge-tree of 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 are backup_store::tests privacy 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, and cargo fmt --all -- --check are clean. cargo +1.91.1 check -p extenddb-core -p extenddb-engine -p extenddb-server --all-targets passes.
  • The clippy step of .github/workflows/wasm.yml is 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.
  • The gate test four_operations_count_a_name_in_utf16_code_units sends 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 at CreateTable 2 characters. With a count of one code unit more than the name has, it fails at CreateTable 128 characters, the name of 127 😀 followed by a.
  • Against ExtendDB on SQLite, tests/python/test_nul_table_name_fields.py, tests/python/test_nul_table_names.py, tests/python/test_nul_arn_shapes.py and tests/test_table_operations.py passed 139 tests. TestSeveralConstraintsAtOnce::test_utf16_code_units asserts 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.
  • At b8c544bf3, the first form of the first commit, 19 operations outside the list each got 😀😀, 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

  • 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, DescribeTable, DeleteTable or UpdateTable with a TableName outside 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.

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 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.

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));

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.

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.

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.

2 participants