Repository navigation
Conversation
Check Database aborted on the decode error, so the collection could not be repaired from inside Anki, and the message did not say which notetype or template was at fault.
Five names were added upstream since this branch was cut. Taking main's list and keeping my line at the end, so the file no longer conflicts.
# Conflicts: # CONTRIBUTORS
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue (required)
Fixes #5759
Summary / motivation (required)
The collection in #5759 had one
templatesrow whose config blob did not decode, and Anki showed only:Two problems follow from that, and this addresses both:
Check Database could not repair it.
check_notetypesloads each notetype withself.get_notetype(ntid)?, so an undecodable row propagated the error and aborted the whole check. A missing notetype is already handled a line below, by building a recovery notetype and keeping the notes, but a corrupt one was fatal, which left the reporter editing the SQLite file by hand. An undecodable notetype is as unusable as a missing one, so it now takes the same path and counts towards the existingnotetypes_recoveredtotal, reported by the existing "Notetypes recovered" message. OnlyAnkiError::ProtoErroris treated this way; every other error still propagates.The message did not say what was broken. The three decode sites in
rslib/src/storage/notetype/mod.rsnow name what they were reading, so the error readsinstead of the bare decode failure. That is enough to find the row, which is what the reporter had to work out by hand.
No new translatable strings, and no change for a collection that decodes cleanly.
Steps to reproduce (required, use N/A if not applicable)
update templates set config = <70 junk bytes> where ntid = <id>.How to test (required)
Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
Two tests in
rslib/src/dbcheck.rs:corrupt_template_configwrites 70 junk bytes over a template config, clears the notetype cache so the next read comes from the database as it would after a restart, and asserts the check reportsnotetypes_recovered: 1, that the note survives, and that a second run is clean. Before the change this test fails withProtoError { info: "failed to decode Protobuf message: invalid varint" }.corrupt_template_config_names_the_templateasserts the surfaced error names the template and the notetype id.cargo test -p anki: 749 tests pass, 747 of them before these two.cargo clippy -p anki --testsis clean. I was not able to run the full./ninja checkhere, as the Python and web halves need a larger toolchain than I have set up; the Rust crate this touches is covered above.Before / after behavior (optional)
Before: Check Database fails with a decode error and the collection cannot be repaired in-app.
After: Check Database rebuilds the unreadable notetype, keeps the notes, and reports it; any error raised elsewhere names the notetype and template.
Risk / compatibility / migration (optional)
Recovery only runs for a notetype that cannot be decoded, which is already unusable. It reuses
recover_notetype, the path a missing notetype has always taken.UI evidence (required for visual changes; otherwise N/A)
N/A
Scope