Archive: single-key shortcuts, density and other preferences are not exported, and a switch set off is never restored #464

Closed
opened 2026-10-01 10:46:53 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing export.PROFILE_FIELDS with accounts.Profile and round-tripping an archive on an in-memory database.

Checked again on 2026-10-01 against main at 0a5cad587: still present.

The archive carries the theme, the dashboard, the navigation and the table layout, on the rule that an arrangement belongs to the account and travels with it (#123, #299). Several preferences of the same kind are left out, so a restore silently resets them to their defaults. Adding them to the export is not enough on its own: the importer skips every falsy value, so a switch the person turned off would still be restored on, and a deliberately cleared dashboard already comes back full.

  • Where: core/export.py:90-111 (PROFILE_FIELDS); core/importer.py:367-371 in load (if hasattr(profile, name) and value:); the profile fields at accounts/models.py:317 (keyboard_shortcuts), :328 (nav_underline), :340 (density), :352 (plugins_off), :365-368 (keep_page_source, keep_page_rendering) and :407 (closing_notice_days).
  • What happens:
    1. None of keyboard_shortcuts, nav_underline, density, plugins_off, keep_page_source, keep_page_rendering or closing_notice_days appears in the archive. An account exported with shortcuts off, compact density and a ten-day closing notice came back with shortcuts on, comfortable density and three days.
    2. With "keyboard_shortcuts": false added to an archive by hand, the restored account still had shortcuts on, because value is false and the importer passes over it. The same test already loses data today: an account that cleared its dashboard (dashboard_widgets: []) is restored with the seven widgets that accounts/signals.py seeds into every new profile.
  • Why it matters: switching single-key shortcuts off is the WCAG 2.1.4 escape for people who dictate (#227). After a restore it is back on, and a dictated "d" on the capture review can discard a listing. The capture-keeping switches are privacy choices, and a deliberately empty dashboard is a choice #123 set out to preserve.
  • Fix: add these fields to PROFILE_FIELDS and bump FORMAT_VERSION. In load, restore a field when its key is present (if name in PROFILE_FIELDS and hasattr(profile, name)), not when its value is truthy, and validate each value against the field (a choice for density, the range for closing_notice_days, the installed plugins for plugins_off) before setting it.

Done when

  • A round-trip test in tests/test_export.py sets every exported profile field to a non-default value, including keyboard_shortcuts=False and dashboard_widgets=[], exports, imports into a fresh account and asserts each one survived.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing `export.PROFILE_FIELDS` with `accounts.Profile` and round-tripping an archive on an in-memory database. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The archive carries the theme, the dashboard, the navigation and the table layout, on the rule that an arrangement belongs to the account and travels with it (#123, #299). Several preferences of the same kind are left out, so a restore silently resets them to their defaults. Adding them to the export is not enough on its own: the importer skips every falsy value, so a switch the person turned off would still be restored on, and a deliberately cleared dashboard already comes back full. - **Where:** `core/export.py:90-111` (`PROFILE_FIELDS`); `core/importer.py:367-371` in `load` (`if hasattr(profile, name) and value:`); the profile fields at `accounts/models.py:317` (`keyboard_shortcuts`), `:328` (`nav_underline`), `:340` (`density`), `:352` (`plugins_off`), `:365-368` (`keep_page_source`, `keep_page_rendering`) and `:407` (`closing_notice_days`). - **What happens:** 1. None of `keyboard_shortcuts`, `nav_underline`, `density`, `plugins_off`, `keep_page_source`, `keep_page_rendering` or `closing_notice_days` appears in the archive. An account exported with shortcuts off, compact density and a ten-day closing notice came back with shortcuts on, comfortable density and three days. 2. With `"keyboard_shortcuts": false` added to an archive by hand, the restored account still had shortcuts on, because `value` is false and the importer passes over it. The same test already loses data today: an account that cleared its dashboard (`dashboard_widgets: []`) is restored with the seven widgets that `accounts/signals.py` seeds into every new profile. - **Why it matters:** switching single-key shortcuts off is the WCAG 2.1.4 escape for people who dictate (#227). After a restore it is back on, and a dictated "d" on the capture review can discard a listing. The capture-keeping switches are privacy choices, and a deliberately empty dashboard is a choice #123 set out to preserve. - **Fix:** add these fields to `PROFILE_FIELDS` and bump `FORMAT_VERSION`. In `load`, restore a field when its key is present (`if name in PROFILE_FIELDS and hasattr(profile, name)`), not when its value is truthy, and validate each value against the field (a choice for `density`, the range for `closing_notice_days`, the installed plugins for `plugins_off`) before setting it. ## Done when - A round-trip test in `tests/test_export.py` sets every exported profile field to a non-default value, including `keyboard_shortcuts=False` and `dashboard_widgets=[]`, exports, imports into a fresh account and asserts each one survived.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:46:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#464
No description provided.