[ERROR] Restore to Default: note has 3 fields, expected 2

Steps to reproduce

  1. Make a basic note.
  2. Open it in the note editor.
  3. Click on fields and add a field.
  4. Click on cards then restore to default from the upper right corner.

Actual behavior

You get an error “note has 3 fields, expected 2”.

Expected behavior

No error.

Additional information

On AnkiDroid, you don’t get an error immediately, but if you try to save the edit, you get this error

java.lang.lndexOutOfBoundsException: Index 2 out of bounds for length 2

Debug info

Anki 25.09.2 (3890e12c) (ao)
Python 3.13.5 Qt 6.9.1 PyQt 6.9.1
Platform: Windows-10-10.0.19045-SP0

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Advanced Copy Fields ['1898445115', 2024-01-08T20:01, 'v0.4.01', '']
AnkiConnect ['2055492159', 2025-11-09T22:40, 'None', mod]
AnkiWebView Inspector ['31746032', 2023-06-27T22:26, 'None', '']
Disconnected Review-Log Cleaner ['1067771610', 2025-06-10T16:28, 'None', '']
Local Audio Server for Yomichan ['1045800357', 2023-06-19T06:57, 'None', '']
The KING of Button Add-ons ['374005964', 2025-01-28T01:26, 'None', mod]

===IDs of active AnkiWeb add-ons===
1045800357 1067771610 1898445115 2055492159 31746032 374005964

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
No Distractions Full Screen Fixed by Shige ['1370336700', 2024-08-26T08:08, 'None', mod]
1 Like

I cannot reproduce this on Desktop (didn’t try AnkiDroid).

My steps:

  1. Open “Manage Note Types” (e.g. Ctrl+Shift+n).
  2. Click “Add”.
  3. Choose “Add: Basic” and then click “OK”.
  4. Name it “Basic_Test”.
  5. Select “Basic_Test” and click “Fields”.
  6. Click “Add” and name the field, e.g. “DDDD”.
  7. Press “Save”.
  8. Click “Cards”.
  9. Click “Options”, then “Restore to Default…”.
  10. Accept with “Yes”.

My result

The note gets properly reset. The templates and the fields are back to the initial value.

My Anki Version

Anki 25.09.2 (3890e12c) (ao)
Python 3.13.5 Qt 6.9.1 PyQt 6.9.1
Platform: Linux-6.12.41+deb13-amd64-x86_64-with-glibc2.41

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
'' ['Convert_ODS_to_CSV_then_import', 0, 'None', '']
'' ['myaddon', 0, 'None', '']
AnkiWebView Inspector ['31746032', 2023-06-27T21:26, 'None', '']
Image Occlusion Enhanced ['1374772155', 2022-04-09T09:15, 'None', '']
Modern Stats Dashboard ['1063901297', 2025-06-28T21:14, 'None', '']
Review Heatmap ['1771074083', 2022-06-30T03:43, 'None', '']
Search Stats Extended ['1613056169', 2026-01-17T19:00, 'None', mod]
Simple Forvo Audio Downloader ['560814150', 2024-09-08T15:03, 'None', mod]
Study Time Stats ['1247171202', 2024-02-24T17:59, 'None', '']
Wrapper meta-addon ['396502676', 2025-07-09T17:27, 'None', '']

===IDs of active AnkiWeb add-ons===
1063901297 1247171202 1374772155 1613056169 1771074083 31746032 396502676 560814150

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Study Time Stats ['_______1247171202', 2024-02-24T17:59, 'None', '']

You need to restore to default from the note editor. You seem to be mixing notes and note types.

Ah, I see. So basically from the Add note dialog (this one with the picture Adding/Editing - Anki Manual)? I still cannot reproduce, though. Did I still misunderstand maybe?

My steps

  1. Open “Manage Note Types” (e.g. Ctrl+Shift+n).
  2. Click “Add”.
  3. Choose “Add: Basic” and then click “OK”.
  4. Name it “Basic_Test”.
  5. Press “Close”.
  6. Click “Add”.
  7. Select Type “Basic_Test” (mine was pre selected).
  8. Click “Fields…” and add a random field, then save.
  9. Click “Cards…”.
  10. Click “Options”, then “Restore to Default…”.
  11. Accept with “Yes”.

My result

The note gets properly reset. The templates and the fields are back to the initial value. The Add note dialog gets updated properly as well.

Edit: Same when editing the note via the browser btw, after a note had been added with that note type.

1 Like

Ok sorry for the confusion, these steps should work:

  1. Create a test deck.
  2. Add a basic note to it.
  3. Open it in the study screen.
  4. Click on edit.
  5. Click on fields and add a field.
  6. Click on cards and then restore to default.

The crucial part you were missing is to actually add the note, then open it in the note editor.

Also, it seems to only happen in the study screen.

Weird. I still cannot reproduce. I also tested all of the above in a completely new profile. Sounds unlikely to me that this is a Windows issue but I cannot imagine why I wouldn’t be able to reproduce if this was an platform-independent Anki issue.

1 Like

I can reproduce it:

1 Like

I was also able to reproduce the bug behavior on Mac desktop Anki 25.09.2

I suspect that the bug occurs because, in this workflow, the “Edit Current Card” window is open when the cards/fields are reset back to default.

  1. The Edit Current Card window starts with 3 fields.
  2. The cards/fields are reset back to default.
  3. The error dialog appears. At this point, the Edit Current Card window still shows 3 fields.
  4. After closing dialogs, the Edit Current Card window then shows 2 fields.

Steps to Reproduce:

  1. (I first created a new profile and switched to it, to avoid messing up my personal decks.)
  2. “Create Deck”, enter the new Deck name, and press “OK” to create the new deck.
  3. “Add” to bring up the Add window, enter text into the Front and Back fields for a new Basic note, and “Add” the new Basic note.
  4. “Close” the Add window.
  5. Enter the deck and “Study Now” to study the new card.
  6. “Edit” the note.
  7. “Fields…” to bring up the Fields for Basic window.
  8. “Add”, enter the new Field name, and press “OK” to add the new field.
  9. “Save” to save the fields.
  10. “Cards…” to bring up the Card Types for Basic window.
  11. “Options” → “Restore to Default…” → “Yes”
  12. Two dialogs appear:
    1. Note type has been restored to its original state.
    2. note has 3 fields, expected 2. (You have reproduced the bug.)
  13. Observe that the Edit Current window still shows 3 fields.
  14. Close dialog 2 by pressing “Close”.
  15. Close dialog 1 by pressing “OK”.
  16. Observe that the Edit Current window now shows 2 fields.
4 Likes

Yes, it’s caused by the editor trying to save an old copy of the note with only 2 fields.

1 Like

Yes, please do. My “Edit Current” window stays open as well but the fields update just fine (3 become 2 as expected). It happens instantly without me having to close and re-open that window.

Nothing relevant in the terminal either if ran with anki --safemode; no error, warning or info message that is out of the ordinary.

Not for me it doesn’t. I uploaded a demonstration at Adding a new field from the editor then resetting the template from Card Layouts causes an error · Issue #4540 · ankitects/anki · GitHub since videos cannot exceed 512 KB on this forum.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.