ui.genetic_miner: dependent slider values are not clamped when their bounds change #30

Open
opened 2026-10-06 13:49:37 +00:00 by ffrauenberger · 1 comment
Owner

Severity: low (plausible: the effect depends on the Streamlit version)

Where

  • app/ui/genetic_miner_ui/genetic_miner_controller.py:114-134
  • app/components/number_input_slider.py:42-66

Problem

Found by code review; exact effect depends on the Streamlit version.

Some slider bounds depend on other inputs, e.g. tournament_size ∈ [2, min(20, population_size)]. When the user lowers Population Size below the current Tournament Size, the stored value (st.session_state.tournament_size, mirrored to tournament_size_text_input) is above the new max_value, and nothing clamps it. The miner itself guards with min(tournament_size, population_size), so the UI and the value actually used disagree.

Steps to reproduce

  1. Select the Genetic Miner
  2. Set Tournament Size to 10
  3. Lower Population Size to 5

Expected behavior

Tournament Size is clamped to 5 and the widget shows the value actually used.

Actual behavior

Depending on the Streamlit version, number_input raises StreamlitValueAboveMaxError, or the widget shows a value outside its range.

Fix

Clamp dependent session values in process_algorithm_parameters before the widgets are created.


from issues/BUG-030-dependent-slider-bounds-not-clamped.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** low (plausible: the effect depends on the Streamlit version) ## Where - `app/ui/genetic_miner_ui/genetic_miner_controller.py:114-134` - `app/components/number_input_slider.py:42-66` ## Problem *Found by code review; exact effect depends on the Streamlit version.* Some slider bounds depend on other inputs, e.g. `tournament_size ∈ [2, min(20, population_size)]`. When the user lowers *Population Size* below the current *Tournament Size*, the stored value (`st.session_state.tournament_size`, mirrored to `tournament_size_text_input`) is above the new `max_value`, and nothing clamps it. The miner itself guards with `min(tournament_size, population_size)`, so the UI and the value actually used disagree. ### Steps to reproduce 1. Select the Genetic Miner 2. Set *Tournament Size* to 10 3. Lower *Population Size* to 5 ### Expected behavior *Tournament Size* is clamped to 5 and the widget shows the value actually used. ### Actual behavior Depending on the Streamlit version, `number_input` raises `StreamlitValueAboveMaxError`, or the widget shows a value outside its range. ## Fix Clamp dependent session values in `process_algorithm_parameters` before the widgets are created. --- from `issues/BUG-030-dependent-slider-bounds-not-clamped.md` (code analysis of commit 6bcc646, 2026-10-03)
Author
Owner

Reviewed by Codex (GPT-6) against origin/main 6bcc646eb464.

Review: partially correct.

The application has no explicit dependent-value clamp, but the current reproduction needs correction. In the reviewed Nix environment (Streamlit 1.58.0), an AppTest of this helper starts Tournament Size at 10 with Population 20; reducing Population to 5 resets both tournament widgets to 2, with no exception. It does not leave 10 displayed outside the range. That still differs from the expected clamp-to-5 behavior.

Separately, pre-seeding a fresh widget with value 10 and bounds 2–5 reproduces StreamlitValueAboveMaxError at st.slider, before number_input is reached. Distinguish the bound-change reset behavior from an initially invalid state. The proposed explicit clamp is still reasonable.

Code references: app/components/number_input_slider.py:45, app/ui/genetic_miner_ui/genetic_miner_controller.py:129.

Reviewed by **Codex (GPT-6)** against origin/main [`6bcc646eb464`](https://code.swisdata.eu/ffrauenberger/ProcessIntel/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4). **Review: partially correct.** The application has no explicit dependent-value clamp, but the current reproduction needs correction. In the reviewed Nix environment (Streamlit 1.58.0), an AppTest of this helper starts Tournament Size at 10 with Population 20; reducing Population to 5 resets both tournament widgets to **2**, with no exception. It does not leave 10 displayed outside the range. That still differs from the expected clamp-to-5 behavior. Separately, pre-seeding a fresh widget with value 10 and bounds 2–5 reproduces `StreamlitValueAboveMaxError` at **`st.slider`**, before `number_input` is reached. Distinguish the bound-change reset behavior from an initially invalid state. The proposed explicit clamp is still reasonable. Code references: [app/components/number_input_slider.py:45](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/components/number_input_slider.py#L45), [app/ui/genetic_miner_ui/genetic_miner_controller.py:129](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/ui/genetic_miner_ui/genetic_miner_controller.py#L129).
Sign in to join this conversation.
No milestone
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
ffrauenberger/ProcessIntel#30
No description provided.