Repository navigation
fix(engine): end a failed ImportTable as DynamoDB does - #1370
LeeroyHannigan wants to merge 12 commits into
Conversation
A DYNAMODB_JSON line the import could not read answered the request with ValidationException and "Invalid DynamoDB item at line N". Nothing was imported, and the table created before the read stayed empty. Measured on DynamoDB in us-east-1 on 22 November 2026, twice with the same answers. A line the import cannot read is one error and ends the reading of its file. Such a line is not JSON, has no "Item" member, or has a B value that is not padded base64. The items before it stay imported. The lines after it are neither imported nor counted. An item that fails a check (no key, a key of another type) is one error, and the import reads the next line. The import skips an empty line. ProcessedItemCount is the imported items plus the errors. The import ends FAILED with ItemValidationError, and the table keeps the imported items. For the eight measured files: ProcessedItemCount 14, ImportedItemCount 8, ErrorCount 6. The reader now returns the items before the first line it cannot read, with the number and the fault of that line. The handler counts the line as one error after those items. The check of an item, the FAILED status and the message that names the server log are the ones already there. Before, the reader took a line without an "Item" member as a bare item. The service refuses such a line. The ION format shares the reader. CSV is unchanged. The request's own errors (the source path, the item count limit, I/O) are unchanged. Fixes #1357.
The base merges #1260's branch twice, which brings #544's newer commits, and adds a doc comment to its import test. The merge has no conflict. Of the files this branch changes, git merged two with changes from the base. In crates/engine/src/import_export_io.rs the base extends the doc comment of import_reads_a_binary_only_in_the_canonical_form. In docs/troubleshooting.md the base changes the catalog-check entry, which is not the import entry that this branch changes.
…t end a file
The troubleshooting entry for an import that ends FAILED named three
kinds of line that end the import of a file. A line whose Item the item
reader refuses, such as {"Item": {"pk": {"Q": "x"}}}, ends the file too:
read_line answers "Invalid DynamoDB item" for it. The entry now gives
the lines and the item that end a file as a list, with this line added.
This branch changes two ImportTable answers that an existing client can see. A file of lines without an Item member imported its lines, and now it imports nothing. A file with a line the import cannot read answered HTTP 400 and left the new table empty. Now the request answers HTTP 200 with ImportStatus FAILED, and the items before the line stay imported. The upgrade manual gets a v1.1.0 entry for both changes, as the earlier ImportTable change of #620 has an entry.
The base merges main at 14ade59. That brings #544 as a squash and ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584, #588 and #864. One file conflicted: crates/engine/src/import_export.rs. #1009 moves the body of handle_import_table to import_table in the new file crates/engine/src/import_export/files.rs. The wasm32 build replaces that file with a stand-in that refuses the operation. handle_import_table keeps the enabled check and calls files::import_table. This branch changes the body that #1009 moves. When read_items finds a line that it cannot read, the import keeps the items before that line. It counts the line as one error and reads no more of the file. The merge keeps the code of main in import_export.rs, with the doc comment of this branch on handle_import_table. It makes the three changes of this branch to the body in files.rs: - The variable read holds the result of read_items: the items and the line that the reader cannot read. - The loop takes the items, then that line. At that line it logs the line number and the fault, counts one error and ends the import. - The comment over the FAILED status adds the date 2026-11-22, for the lines that the import cannot read. The body of import_table in files.rs is now the same as the body of handle_import_table at the head of this branch. Git merged docs/manuals/07-upgrade-manual.md with no conflict. #398 adds its v1.1.0 entry at the top of "Behavior Changes by Release". This branch adds its v1.1.0 entry at the end of that section.
navareamol
left a comment
There was a problem hiding this comment.
fd1c1e1 no longer merges with main. Main at 92155f3 moved the v1.1.0 entries of docs/manuals/07-upgrade-manual.md in #1514, and a three way merge of this head with it conflicts in that file. No code file conflicts. The description says the merge with main at 5252eda has no conflict, which still holds for 5252eda. #1514 is tagged v1.1.0, so the new entry "v1.1.0: an ImportTable line that cannot be read ends its file, and each line needs an Item member" now names a release that shipped without this change. Could you merge main and move the entry under the next release? I merged it here keeping main's side plus this entry: fmt, a workspace check of all targets, clippy on core and engine, the core lib (1243) and engine lib (981) tests, and tests/test_import_export.py with four other wire files on SQLite (265) pass. The wasm check on this head fails with E0308 at crates/core/src/metrics/collector.rs:60, the error main had before #1482, so CI on the merged branch would also clear that.
A file that starts with a UTF 8 byte order mark (EF BB BF) followed by two good {"Item": ...} lines now answers 200 with ImportStatus FAILED, counts (1, 0, 1) and an empty table. #1313's head and main answer 400 Invalid JSON at line 1. trim() keeps U+FEFF, so line 1 is not JSON and ends the file. Was such a file among the ones measured on the service? If the service reads it, I think the reader should drop a leading U+FEFF on line 1.
I will approve once the branch is merged with main, the upgrade manual entry names the next release, and CI is green on that tree.
The base merges main at 01556cf, 27 commits past 14ade59, through #1260. That brings #1514, which released v1.1.0 and moved the v1.1.0 entries of docs/manuals/07-upgrade-manual.md to the top of "Behavior Changes by Release". The base also checks only the items and keys of BatchWriteItem for padding, and check_binaries now takes one attribute value. Two files conflicted: - docs/manuals/07-upgrade-manual.md: this branch added its v1.1.0 entry at the end of "Behavior Changes by Release". The conflict hunk also holds the earlier copy of the ClientRequestToken entry, which main moved and rewrote. The merge keeps the side of main. The entry of this branch is now a v1.2.0 entry at the top, after the v1.2.0 entry of #1260, since v1.1.0 shipped without this change. - crates/engine/src/import_export_io.rs: this branch moved the line check to read_line, and the base changed the call of check_binaries there. The merge keeps read_line and calls check_binaries on each value of the item. Git merged docs/troubleshooting.md with no conflict. Main changes the entries at lines 330 to 470, and this branch changes the import entry at line 1029.
The base merges main at e8b5f10 through #1260, which brings #481, #1137 and #1403. #1403 adds a v1.2.0 entry for #606 at the top of "Behavior Changes by Release" in docs/manuals/07-upgrade-manual.md, above the entry of #1260. Git merged the file with no conflict, so the order is #606, #1260, then the entry of this branch.
|
The branch merges main through #1313 and #1260: d23563c for main at 01556cf, then da4d5c9 for main at e8b5f10. The conflict in The byte order mark: no measured file started with one. A measurement needs an ImportTable, which creates a table, and this round creates no resource on the service. Without the answer of the service, the reader keeps its rule. Line 1 with U+FEFF is not JSON, so it ends the file, as line 2 of file c does. |
The base brings main at c8e66fb through #1260, with #1465, #1515 and #1411, and adds the v1.2.0 entry of #1313 to docs/manuals/07-upgrade-manual.md. Git merged the manual with no conflict. The order of the v1.2.0 entries is #1313, #1411, #606, #1260, then the entry of this branch. No other file has changes on both sides.
|
The merge with main and the upgrade note are fixed. The v1.2.0 entry of #1260 now disagrees with yours. It ends with "An ImportTable line with such a value keeps its 1.1.0 answer, I checked the call of On the byte order mark, I take it that no measured file had one and that you cannot measure it without creating a table, so the rule stays. I agree that stripping U+FEFF would be a guess too. The description names it under "Changes since the last review". The upgrade entry does not, so a user whose tool writes a byte order mark would learn from the manual only that bad lines end the file. One sentence there that a file starting with a byte order mark ends FAILED at line 1 would help, but I do not need it for approval. The head has since moved to c76a612, another merge of main. The #1260 sentence is unchanged there. Checks on it are still running: 38 passed and 29 pending when I looked, none failed. I will approve once the #1260 sentence matches your entry and the checks on the branch are green. |
The base brings a new BatchWriteItem check. It reads a fault ahead of a B in request order, also inside a value. The base also adds a sentence to its v1.2.0 entry. The merge has no conflict. Git merged the upgrade manual, where both sides changed other lines. The base adds the new sentence to the entry of #1313. This branch has its entry below the entry of #1260. No other file has changes on both sides.
The v1.2.0 entry of #1260 ended with "An ImportTable line with such a value keeps its 1.1.0 answer, Invalid DynamoDB item at line N". The entry of this branch says that such a line now ends the reading of its file. The sentence in the entry of #1260 now gives the 1.1.0 answer and the new one. The request answers HTTP 200, and the import ends FAILED. The entry of this branch now also says what a file that starts with a UTF-8 byte order mark gets. The reader does not take U+FEFF as JSON, so the reading ends at line 1 and the import ends FAILED. No measured file started with a byte order mark.
The base changes one sentence of its v1.2.0 entry. It now says that 1.1.0 answered such a BatchWriteItem request with the text of the other fault. The merge has no conflict.
|
a3ef625 changes the sentence in this branch. The v1.2.0 entry of #1260 now ends with "An ImportTable line with such a value got The same commit adds the byte order mark to the entry of this PR. The reader does not take a UTF-8 byte order mark at the start of a file as JSON. So the reading of such a file ends at line 1, and the import ends c6813fe merges #1313's new head 6825c8e, which changes the BatchWriteItem check inside a value. The merge has no conflict, and |
|
The #1260 sentence now reads "An ImportTable line with such a value got The byte order mark sentence matches the reader: crates/engine/src/import_export_io.rs trims each line with trim(), which keeps U+FEFF, so line 1 of such a file is not JSON and the file ends there. On da4d5c9 I measured 200 with FAILED, counts (1, 0, 1) and an empty table on SQLite. That no measured file started with a byte order mark is your statement, and I have not measured the service. Main has moved to c057660 (#1446) and a merge of it into this head conflicts in docs/manuals/07-upgrade-manual.md, where main added six lines. No code file conflicts, and the head of #1313 conflicts in the same way. On babe801, 4 checks had passed and 36 were queued or running when I looked. I will approve once main is merged and the checks on that head are green. |
The base brings main at b6c8595 through #1260, with #1446, #1531 and #1466, and the 15 new rows of #1260 in tests/test_binary_base64.py. The merge has no conflict. Git merged the upgrade manual, where both sides changed other lines. The base adds the two entries of main above the entry of #1313, and this branch has its entry below the entry of #1260. No other file has changes on both sides.
|
@navareamol dfff876 merges the new head of #1313, which brings main at b6c8595 through #1260. Git merged the upgrade manual with no conflict. The two entries of main are at the top, and the entry of this PR stays below the entry of #1260. No code file has changes on both sides. The checks run again on this head. |
navareamol
left a comment
There was a problem hiding this comment.
Main has moved again, to 5826e1b (#1087). A merge of it into dfff876 conflicts in docs/manuals/07-upgrade-manual.md, where #1087 added the entry "SQLite parallel Scan segments follow the partition key". No code file conflicts, and the head of #1368 conflicts in the same way, so this comes from main moving under the stack. On dfff876, 39 checks had passed, 1 was cancelled (conventional) and 28 were running or queued when I looked.
The byte order mark sentence holds on this head. On a SQLite build of dfff876, an ImportTable file that starts with U+FEFF answers HTTP 200 and the import ends FAILED with counts (1, 0, 1) and an empty table, whether the mark sits on its own line or before the first item. A mark at the start of line 2 keeps the item of line 1 and ends the file there. A UTF-16 mark fails the request with HTTP 400 and the I/O error text, as the entry says for a line that is not UTF-8. When I strip U+FEFF before the line is read, the same files import and end COMPLETED, so the sentence depends on the reader as it is. That no measured file started with a byte order mark is your statement, and I have not measured the service.
The sentence in the entry of #1260 matches this entry, so the manual gives one answer. The head differs from the one I read before only by merges of main and of #1313, and read_line is unchanged.
All 70 checks pass on dfff876, so I approve. The manual conflict with main sits in the whole stack, and the stack can fix it when it lands.
Changes since the last review
tests/test_binary_base64.py. The merge has no conflict. Git merged the upgrade manual, where both sides changed other lines. The base adds the two entries of main at the top, and the entry of this PR stays below the entry of fix(core): send DynamoDB's text for a B value that does not decode #1260. No other file has changes on both sides.cargo +1.97.0 fmt --all -- --checkis clean..github/workflows/clippy.ymlwith-D warnings, on the whole workspace as CI runs them, are clean.cargo +1.94.0 check --all-targetsis clean onextenddb-coreandextenddb-engine.cargo test -p extenddb-wasm-adapterpasses, with itsparitycorpus test.cargo test -p extenddb-storage-postgres --test doc_version_literalspasses..github/workflows/wasm.ymlis clean.devtools/run-testssets it,tests/test_import_export.py,tests/test_binary_base64.py,tests/test_query_leading_keys_values.pyandtests/test_query_value_shapes.pypassed 226 tests each.python3 -m pytest --collect-only -qcollects 7380 tests intests/and 820 intests/pythonwith no error.What
An ImportTable of
DYNAMODB_JSONnow ends as DynamoDB does when it cannot read a line of a file. Before, the request answeredValidationExceptionwithInvalid DynamoDB item at line NorInvalid JSON at line N. It imported nothing, and the new table stayed empty.With this PR, a line that the import cannot read is one error and ends the reading of its file. The items before it stay imported. The lines after it are not imported or counted. Such a line is not JSON, has no
Itemmember, or holds aBvalue that is not padded base64. A line whoseItemthe item reader refuses, such as an unknown type descriptor, ends the file too. Before, ExtendDB read a line withoutItemas a bare item.An item that fails a check (no key, a key of another type) is one error, and the import reads the next line. The import then ends
FAILEDwithFailureCodeItemValidationErrorand keeps the imported items. This part is already onmain, from #620. The issue says that such an import endsCOMPLETED, which was the behaviour before #620.The changes:
crates/engine/src/import_export_io.rs:read_itemsandread_dynamodb_jsonreturn the items and the first line they cannot read, with its number and its fault.read_linegives the item or the fault for one line.crates/engine/src/import_export/files.rs:import_table, the body of the ImportTable handler, counts the unread line as one processed row and one error, after the items before it. It writes the line number and the fault to the server log and stops. An item with anNvalue that is not a number still ends the import of its file, as onmain(fix(engine): validate numbers on every key and item path #620).docs/troubleshooting.md: the entryInvalid JSON at line NbecomesAn import ends FAILED with ItemValidationError. The module comment ofcrates/core/src/backup_format/data_file.rschanges to match.docs/manuals/07-upgrade-manual.md: a v1.2.0 entry gives the two changes of the Breaking changes section. The last sentence of the entry of fix(core): send DynamoDB's text for a B value that does not decode #1260 changes to match. An ImportTable line with aBvalue that does not decode gotInvalid DynamoDB item at line Nin 1.1.0, and now it ends the reading of its file.The
IONformat uses the same reader, so it gets the same rules.CSVdoes not change. TheFailureMessagekeeps ExtendDB's text, which names the server log. DynamoDB's text names CloudWatch. #620 set that text, anddocs/differences-from-dynamodb.mdlists the difference in the rowImported rows holding a number the service cannot store.The base of this PR is #1313.
Why
Fixes #1357
These are DynamoDB's answers, measured in us-east-1 on 22 November 2026. The same eight files went into two S3 prefixes. One ImportTable per prefix (
DYNAMODB_JSON, no compression, a new table keyed onpkof type S) gave the same answers both times. The counts are (ProcessedItemCount, ImportedItemCount, ErrorCount).{"B": "YQ"}, A3Invalid DynamoDB item at line 2, no itemsFAILED(2, 1, 1), A1Invalid JSON at line 2, no itemsFAILED(2, 1, 1), C1pk, D2FAILED(2, 1, 1), D2pkof type N, E2FAILED(2, 1, 1), E2COMPLETED(2, 2, 0){"B": "YQ"}, G2Invalid DynamoDB item at line 1, no itemsFAILED(1, 0, 1), noneCOMPLETED(2, 2, 0){"pk": {"S": "J1"}}with noItem, J2COMPLETED(2, 2, 0), J1 and J2FAILED(1, 0, 1), noneDynamoDB read the eight files in one import. It ended
FAILEDwithItemValidationErrorand the counts (14, 8, 6). ExtendDB reads one file per import, and its eight imports add up to (14, 8, 6). For a line it cannot read, DynamoDB writes the fault andRemainder of the file will not be processed.to CloudWatch. ExtendDB's server log gives the line number and the fault. For a line that is not JSON, has noItemmember or holds aBvalue that is not padded, the fault is DynamoDB's text.Not measured on DynamoDB: a line whose
Itemthe item reader refuses, such as an unknown type descriptor. ExtendDB ends the file there. TheIONandCSVformats and a compressed file are not measured either. No measured file started with a UTF-8 byte order mark. The reader does not take the mark as JSON, so the reading of such a file ends at line 1, and the import endsFAILED. A measurement needs an ImportTable, which creates a table.Not in this PR
ValidationExceptionI/O error reading import file at line N. The handler reads the file after it creates the table, so that request leaves an emptyACTIVEtable, the end state that ImportTable answers an item it cannot read with an error and leaves an empty table, where DynamoDB imports the rest and ends FAILED #1357 describes. The reader's other request errors, such as the item limit of the deployment, take the same path. DynamoDB's answer to such a line is not measured. ImportTable: a line that is not UTF-8 fails the request and leaves an empty table #1475 tracks it.Conflicts
git merge-treeshows no conflict of dfff876 withmainat b6c8595. fd1c1e1 resolved the conflict withmainincrates/engine/src/import_export.rs, and the body ofimport_tableincrates/engine/src/import_export/files.rsholds the handler change of this PR. This PR adds a conflict with one open PR:docs/troubleshooting.md. fix: sync an export's file before it answers, and remove a failed export's file #735 keeps the entryInvalid JSON at line N, which this PR replaces. The resolution keeps the entry of this PR, because that request error is gone.#831, and #1167 on the branch of #831, conflict with the base in
docs/manuals/07-upgrade-manual.md. The v1.2.0 entry of this PR sits below the entry of #1260, above the v1.1.0 entries, where other open PRs add their entries too. Whichever PR merges second keeps both entries.The base #1313 has conflicts of its own.
Testing done
The runs below are on 5854827, before the merges of #1313's new heads, unless a line names another tree. "Changes since the last review" gives the runs on the commits since the last review.
cargo test -p extenddb-core -p extenddb-engine --lib --no-fail-fast: 1147 core unit tests passed and 1 ignored, and 931 engine unit tests passed.cargo +1.97.0 fmt --all -- --checkis clean.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings, the same with--features extenddb-engine/backup-test-hooks, andcargo +1.91.1 check -p extenddb-core -p extenddb-engine --all-targetsare clean.a_line_the_import_cannot_read_ends_the_fileincrates/engine/src/import_export_io.rshas one data table of six measured files.LINE_FILESintests/test_import_export.pyhas six measured files and one row that puts a skipped item before a line that ends the file. The measurement on DynamoDB has those two rules in separate files.devtools/run-testssets it,tests/test_import_export.pypassed 42 tests.test_a_line_the_import_cannot_read_ends_the_import_of_its_file:unpadded-base64-ends-the-file,not-json-ends-the-file,first-line-ends-the-file,no-item-member-ends-the-fileandskipped-item-then-unread-line. A mutant that does not count the unread line as an error fails the same 5 rows. These ran on the merge with fix(core): read a B value with its padding left out or cut short #1313's head, whose Rust files are the same as at 5854827.main(891f30ccf) checks the resolution of the conflict withmain. Its two handler files differ frommainonly by this PR's change. The engine unit tests ofimport_exportpassed on it, andtests/test_import_export.pypassed 42 tests against a SQLite build of it. In one earlier run of that build,TestExportTable::test_export_dynamodb_jsonread 4 lines from an export whose description counted 5 items. This PR does not change the export. The WebAssembly clippy step ofdevtools/run-wasm-step clippyis clean on the scratch merge. 5854827 lacksdevtools/wasm-clippy, which feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 added onmain.python3 -m pytest --collect-only -qcollects 7027 tests intests/and 672 intests/python, with no error.At a3ef625 against #1313's head 6825c8e, the Rust code is +90 -49, with the module comment of
data_file.rs. The Markdown docs are +21 -4, and the tests are +160 -6.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
DYNAMODB_JSONorIONline without anItemmember, such as{"pk": {"S": "J1"}}, is no longer read as a bare item. A file of such lines imported every line before. Now the import ends at the first such line, imports nothing from the file, and endsFAILEDwithItemValidationError. The troubleshooting entry onmaingives the bare form as valid.ValidationExceptionwithInvalid JSON at line NorInvalid DynamoDB item at line N, and left the new table empty. It now answers HTTP 200. ItsImportTableDescriptionhasImportStatusFAILEDandFailureCodeItemValidationError, and the items before the line stay in the table.The v1.2.0 entry of
docs/manuals/07-upgrade-manual.mdgives 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.