Skip to content

SettingsActivity: render non-string setting values as text (fixes "app threw an exception" on settings pages) - #302

Merged
ThomasFarstrike merged 2 commits into
MicroPythonOS:mainfrom
bitcoin3us:fix/settings-row-non-string-values
Sep 16, 2026
Merged

ThomasFarstrike merged 2 commits into
MicroPythonOS:mainfrom
bitcoin3us:fix/settings-row-non-string-values

Conversation

@bitcoin3us

@bitcoin3us bitcoin3us commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since 62e1a09 (settings: dont_persist rows with default_value show (defaults to X)) the settings list hands the stored pref value from _row_value_text() straight to lv.label.set_text(). Prefs are JSON, so a value that was written as a number, by an older app version or through numeric ui_options values, comes back as an int, and set_text raises:

TypeError: can't convert 'int' object to str implicitly
  File "mpos/ui/settings_activity.py", line 117, in onResume

The user sees the "App threw an exception. It might be glitchy. Maybe there's an update that fixes it?" dialog every time that app's settings page opens. Reproduced with ClipTV's buttons_per_screen (stored as 6) on a Waveshare ESP32-S3-Touch-LCD-3.5 running current main.

Fix

_row_value_text() now returns str(...) of the label-mapped value, so any stored type renders as text; the (defaults to X) paths were already safe through their f-strings. One line, plus four unit tests in tests/test_settings_activity_label_mapping.py (int value, int value mapped to a ui_options label, int default, strings unchanged) and a changelog entry.

Verification

  • tests/test_settings_activity_label_mapping.py: 27 tests pass on the desktop build.
  • On the badge, opening ClipTV's settings after the fix is loaded shows the row as "6" with no dialog.

🤖 Generated with Claude Code

With thanks to the scientists and engineers who did the hard, unglamorous work that got us here.

Since 62e1a09 the settings list passes the stored pref value through
_row_value_text() straight into lv.label.set_text(). Prefs are JSON,
so a value written as a number (an older app version, or a numeric
ui_options value) arrives as an int and set_text raises "can't convert
'int' object to str implicitly", which the user sees as the "App threw
an exception. It might be glitchy" dialog every time that settings
page opens. Seen with ClipTV's buttons_per_screen on the Waveshare
ESP32-S3-Touch-LCD-3.5.

Stringify the (label-mapped) value in _row_value_text so any stored
type renders. Defaults were already safe via the f-string.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ThomasFarstrike

Copy link
Copy Markdown
Contributor

Nice catch! And great that you added a test for this because clearly the current tests missed it!

Question: is this an urgent fix for the conference? Or is it only showing up in ClipTV which can probably work around it until the next release...?

@ThomasFarstrike
ThomasFarstrike merged commit a249193 into MicroPythonOS:main Sep 16, 2026
8 of 9 checks passed
@bitcoin3us

Copy link
Copy Markdown
Contributor Author

Sorry for the slow reply — not urgent from our side. It's a regression since 62e1a09 that hits any app whose settings page lists a pref stored as a number; ClipTV's buttons_per_screen is where it reproduced, and ClipTV can carry a trivial workaround (store that value as a string) until the fix ships, so no hotfix release is needed on our account. Several builtin apps also put_int prefs, but only ones that expose such a key through a SettingsActivity page would hit it, and I'm not aware of one that does. Fine to ride the next regular release.

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