Skip to content

Conversation

@kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Dec 17, 2025

Description

Bug found by @Chaitanya-Keyal in discussion here.

Users can de-select all options in a multiselect, leaving their configuration in an invalid state. This can ultimately cause an exception during the xpub export flow.

Current multiselect settings:

  • Coordinators
  • Sig types
  • Script types

Changes in this PR

New UX flow: Enforce selecting at least one option

SettingsSelectionRequiredWarningView

If users try to exit the multiselect options Setting screen with no options selected, they are presented with this warning screen and then re-routed back to the Setting screen. There is no way to escape this flow until at least one option is selected.


Check when loading persistent Settings

If the persistent settings json has a multiselect with no options selected, the Setting's defaults are loaded instead. There's no good flow to notify the user of the issue: imagine the case where all three multiselects are invalid. The resulting additional flow logic to notify the user and have them fix each one would be a mess.

So instead we just ensure that the Views that depend on those multiselect Settings can function properly by initializing the defaults.


Check when loading SettingsQR

We already have failure exceptions for invalid SettingsQRs so we add a new one for multiselects with no options selected.


Discussion

Currently it doesn't make sense to have a multiselect with no options selected. But if we ever need to relax this for some future Setting, we can add a bool to SettingsDefinition like can_select_none and adjust the logic in these 3 places accordingly.


Misc notes

Various tests and flow tests either amended or created to verify each of the 3 new behaviors.

Adds screenshot shown above.


This pull request is categorized as a:

  • Bug fix

Checklist

  • I’ve run pytest and made sure all unit tests pass before submitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • Yes

I have tested this PR on the following platforms/os:

if type(new_settings[entry.attr_name]) == str:
# Break comma-separated SettingsQR input into List
new_settings[entry.attr_name] = new_settings[entry.attr_name].split(",")
elif new_settings[entry.attr_name] is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif new_settings[entry.attr_name] is None:
elif not new_settings[entry.attr_name]:

When all options are de-selected in a multiselect setting, its value is [], this led to the condition failing ([] is NOT None), and so the default values were not being assigned. Simply changing the condition to not ... should work.

The test for this passed because the value was explicitly being set to None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, good catch.

I've reworked this section and built up the related tests to explicitly test for when the value is "", ",", or None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, just a minor nit: might as well add [] to the list in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Updated!

@Chaitanya-Keyal
Copy link
Contributor

Tested ACK. Verified that loading invalid (empty) persistent settings sets the default values and that it is impossible to exit a multiselect settings menu without selecting atleast one option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants