Adding a new field from the editor then resetting the template from Card Layouts causes an error
- Dominant language
- Rust
- Stars
- 30.5k
- Forks
- 3.2k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 72
Description
> Steps to reproduce
>
> Make a basic note.
> Open it in the note editor.
> Click on fields and add a field.
> 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]
>
Originally reported on https://forums.ankiweb.net/t/error-restore-to-default-note-has-3-fields-expected-2/68718
Reproducible in https://github.com/ankitects/anki/pull/4029 but it's only a console error there.
Contributor guide
Research direction
Start by reproducing the steps in the note editor, especially the Fields action followed by restoring the default from Card Layouts. Trace the reset handling and verify that the added field no longer causes a field-count error when the card layout is restored or saved, including the AnkiDroid behavior described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100