Skip to content

fix(knx-gui): reject unparseable integer input instead of resetting to minimum - #110

Closed
detail-app[bot] wants to merge 1 commit into
masterfrom
detail/bug-fix/fix-knx-gui-reject-unparseable-integer-input-inste-a2b997
Closed

detail-app[bot] wants to merge 1 commit into
masterfrom
detail/bug-fix/fix-knx-gui-reject-unparseable-integer-input-inste-a2b997

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Closes #73

Bug

_render_int_param in apps/knx-gui/src/knx_gui/widgets/parameter_widgets.py renders integer parameters (NumberWidget / NumberSliderWidget) as a free-text field with imgui.InputTextFlags_.chars_decimal, which admits .+-*/ (not just digits). On blur, the except ValueError branch silently overwrote the bound value with min_value (commonly 0) and pushed it through on_change — propagating to ProjectService.set_parameter → EventStore.append(SetParameter(...)), persisted to the SQLite event history and replayed on reopen (SetParameter.apply re-assigns param.value). Typing 5.5 into a 50-valued parameter reset it to 0.

Introduced in 09f4904, which switched the control from imgui.drag_int (int-only slider) to input_text + chars_decimal (free-text) but kept the old ValueError → min_value fallback — changing its meaning from "recover from a malformed loaded default" to "silently overwrite invalid user input with the minimum."

Fix

On ValueError, return early instead of substituting min_value. The bound value is already the prior valid value; preserving it rejects the unparseable input and resyncs the buffer via imgui's controlled-buffer semantics on the next frame.

    try:
        clamped = int(new_text)
    except ValueError:
-       clamped = min_value if min_value is not None else 0
+       return

Testing

Added e2e tests (Dear ImGui Test Engine) to apps/knx-gui/src/knx_gui/testing/tests/test_configure_panel.py, driving the real render_param_widget / render_ui_tree paths:

  • test_render_int_param_rejects_unparseable_input_keeps_prior_value — parametrized over the six unparseable buffers the report enumerates (5.5, 1+2, 3*4, 3/4, 0., ""); each asserts on_change does not fire and the prior value is preserved.
  • test_render_int_param_clamps_valid_within_range / _above_max / _below_min — guard the happy-path and both clamp arms aren't regressed by the fix.
  • test_render_int_param_accepts_signed_integer — guards that legitimate +5 / -5 (which int() accepts) still parse and clamp, so a future input-filter narrowing can't over-correct.
  • test_render_int_param_number_slider_widget_rejects_invalid — covers the NumberSliderWidget match arm (same code path as NumberWidget).
  • test_render_ui_tree_rejects_invalid_int_input — end-to-end through the real Configure-panel render path (render_ui_tree → _render_children → _render_param_table → render_param_widget → _render_int_param), the report's exact reproduction.

Bug-catch verified: reintroducing the min_value fallback makes the rejection and end-to-end tests fail with ['0'] == [] / [('p0', '0')] == [] (matching the report's 50 → 0 symptom); restoring the fix makes all pass.

Routine checks clean: uv run pyright, uv run ruff check, uv run ruff format --check (repo root) all pass; full e2e suite under xvfb-run (30 tests: 17 pre-existing + 13 new), knx-gui unit tests (54), and packages unit tests (666) all pass unchanged.


Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from kewde September 19, 2026 11:41
@codecov

codecov Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.56%. Comparing base (7f7ef57) to head (bd00b63).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #110      +/-   ##
==========================================
+ Coverage   61.46%   61.56%   +0.09%     
==========================================
  Files         156      156              
  Lines       11088    11088              
  Branches     1490     1490              
==========================================
+ Hits         6815     6826      +11     
+ Misses       4111     4098      -13     
- Partials      162      164       +2     
Files with missing lines Coverage Δ
...s/knx-gui/src/knx_gui/widgets/parameter_widgets.py 38.55% <100.00%> (+13.25%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kewde
kewde force-pushed the detail/bug-fix/fix-knx-gui-reject-unparseable-integer-input-inste-a2b997 branch from 5623d7d to bd00b63 Compare September 23, 2026 10:22
@detail-app

detail-app Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Closing this pull request because it has had no human activity in 26 days (since 2026-09-23) and was opened 30 days ago. Detail closes its pull requests once they are more than 30 days old and have had no human activity for 14 days.

If this change is still useful, reopen the pull request and Detail won't close it again. To keep a Detail pull request open, add the detail-keep-open label to it.

@detail-app detail-app Bot closed this Oct 20, 2026
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.

[Detail Bug] KNX GUI: Invalid numeric input resets integer parameters to minimum and persists the corrupted value

1 participant