Bug in importing/exporting that duplicates note types

Steps to reproduce the bug:

  • Open a new profile add add some notes (using any default note type) into a deck.
  • Export the deck as .apkg file.
  • Import the .apkg file in a new (empty) profile.
  • The notes will be imported with a note type named “Basic-xxxxx”

I originally thought it was an importing problem; but importing the deck on AnkiDroid creates the exact same note type name, so I think it might be an exporting bug related to naming?

Tested it holding down the Shift key while starting Anki, still the same problem.

I’m on windows 10
Version ⁨2.1.46 (94913ec2)⁩
Python 3.8.6 Qt 5.14.2 PyQt 5.14.2

Edit: The bug happens with any note type that is already present in the collection, not just the default ones.

I believe this is intended behaviour to avoid duplication issues and styling issues.
Solving was deemed non-trivial in this discussion here

I think that the discussion you linked is about two note types with the same name “Basic” but with different styling.
I’m getting the duplication issue even though the note types are exactly the same.
I’ve updated the original post to explain it better.

This is because the note types have different IDs, so Anki treats them as different regardless of whether their contents are identical.
Treating the two types as the same could prevent users from importing notes that have the same first fields as other notes already in the collection just because their note types happen to have identical contents (fields, names, styling, etc.), though their origins could be quite different.
This is admittedly quite easy to solve from the user’s side (e.g. making a trivial change to the templates of the existing type like adding a space so that the two types are treated as different),

@dae maybe Anki could employ a more complex note type comparison approach (after trying ID comparison) where the source type’s contents (including styling) are compared with the contents of all existing types to find a match? Not sure if this is practical or worth the effort.

1 Like