Skip to content

fix(settings): add input validation for BLE PIN, LoRa modem, and ambient lighting#5477

Merged
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-settings-validation-gaps
May 18, 2026
Merged

fix(settings): add input validation for BLE PIN, LoRa modem, and ambient lighting#5477
jamesarich merged 1 commit into
mainfrom
jamesarich/fix-settings-validation-gaps

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

Motivation

A cross-platform settings validation audit (meshtastic/design standards/audits/settings-validation-matrix.md) identified several Android settings fields that accept invalid input silently -- either discarding it with no user feedback or allowing out-of-range values to be written to the device.

Changes

BLE fixed_pin (leading-zero bug): The PIN field used EditTextPreference(Int) which converts text to a UInt internally, stripping leading zeros. Entering "000100" silently became 100, failed the 6-digit length check, and was discarded with no error shown. Now treated as a string input with KeyboardType.NumberPassword, preserving leading zeros and showing an error indicator for incomplete/invalid PINs.

LoRa spread_factor and coding_rate: Previously accepted any unsigned integer. Now rejects values outside the valid ranges (SF: 7-12, CR: 5-8) and shows an error indicator when the current value is out of range.

Ambient lighting current and RGB: Previously accepted any unsigned integer for LED current (valid: 0-31) and RGB channels (valid: 0-255). Now enforces these ranges with error indicators.

Approach

All fixes use the same pattern: reject out-of-range values in the onValueChanged callback (preventing invalid writes) and pass isError = true to the text field when the current value is invalid (giving visual feedback). Extracted helper composables where needed to stay within detekt's method-length and cyclomatic-complexity thresholds.

…ent lighting

- BLE fixed_pin: treat as string to preserve leading zeros; show error
  state for invalid pins instead of silently discarding input
- LoRa spread_factor: reject values outside 7-12 with error indicator
- LoRa coding_rate: reject values outside 5-8 with error indicator
- Ambient lighting current: clamp to 0-31 range with error indicator
- Ambient lighting RGB: clamp to 0-255 range with error indicator

Fixes silent data loss bugs found during cross-platform validation audit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the bugfix PR tag label May 18, 2026
@jamesarich jamesarich added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 1dd47bc May 18, 2026
13 checks passed
@jamesarich jamesarich deleted the jamesarich/fix-settings-validation-gaps branch May 18, 2026 13:05
garthvh added a commit to meshtastic/design that referenced this pull request May 20, 2026
Reflects fixes merged May 2026:
- BLE fixed_pin: now string input, preserves leading zeros, shows error indicator
- LoRa spread_factor: now enforces 7–12 with error indicator
- LoRa coding_rate: now enforces 5–8 with error indicator
- Ambient lighting current: now enforces 0–31 with error indicator
- Ambient lighting RGB: now enforces 0–255 with error indicators

Ref: meshtastic/Meshtastic-Android#5477
thebentern pushed a commit to meshtastic/design that referenced this pull request May 20, 2026
…xes (#106)

* Add tracking issue numbers for tab alignment canonical order

Apple: meshtastic/Meshtastic-Apple#1840
Android: meshtastic/Meshtastic-Android#5543

* Add tracking issues for context menu alignment; standardise on 'Remove'

- Changed canonical label from 'Delete / Remove' to 'Remove' (matches Android + firmware API)
- Apple: meshtastic/Meshtastic-Apple#1841
- Android: meshtastic/Meshtastic-Android#5544

* Update settings validation audit with Android PR #5477 fixes

Reflects fixes merged May 2026:
- BLE fixed_pin: now string input, preserves leading zeros, shows error indicator
- LoRa spread_factor: now enforces 7–12 with error indicator
- LoRa coding_rate: now enforces 5–8 with error indicator
- Ambient lighting current: now enforces 0–31 with error indicator
- Ambient lighting RGB: now enforces 0–255 with error indicators

Ref: meshtastic/Meshtastic-Android#5477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant