Skip to content

[Fix] Slider step validation raises when max is set without min - #1838

Merged
petar-qb merged 3 commits into
mckinsey:mainfrom
winklemad:fix-slider-step-validation-without-min
Aug 20, 2026
Merged

petar-qb merged 3 commits into
mckinsey:mainfrom
winklemad:fix-slider-step-validation-without-min

Conversation

@winklemad

Copy link
Copy Markdown
Contributor

Description

A slider given max and step but no min fails to validate:

import vizro.models as vm

vm.RangeSlider(max=6, step=1)
# TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

validate_step checks that max is set, then uses min regardless:

if info.data["max"] is not None and step > (info.data["max"] - info.data["min"]):

vizro-core/src/vizro/models/_components/form/_form_utils.py

With min unset that subtraction is 6.0 - None, so the error surfaces during model validation and the dashboard never builds. The guard now requires both bounds before comparing step against the range; the existing ValueError and its message are untouched for the case where both are supplied.

The three neighbouring shapes already work and stay working: min and step without max, min and max and step, and step on its own.

validate_step is shared by Slider and RangeSlider, so tests were added on both sides.

Screenshot

Not applicable — no visual change. The effect is that a config which previously raised during validation now builds.

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

Note: this touches authors.md, as does my open PR #1837, so whichever merges second will need a one-line conflict resolved there. The two changes are otherwise independent — #1837 is in _controls/filter.py, this is in _components/form/_form_utils.py.

validate_step guarded on max but then subtracted min unconditionally, so a
slider configured with max and step but no min raised a TypeError during
model validation. Compare step against the range only when both bounds are
given, leaving the existing error for the case where they are.
Copilot AI lite review requested due to automatic review settings August 18, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes Slider/RangeSlider step validation when one or both bounds are missing, and documents the fix.

Changes:

  • Update validate_step to only compare step vs (max - min) when both bounds are provided.
  • Add unit tests for step validation when min and/or max is None.
  • Update authors and add a changelog fragment describing the fix.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vizro-core/src/vizro/models/_components/form/_form_utils.py Prevents TypeError by guarding step validation behind presence of both bounds.
vizro-core/tests/unit/vizro/models/_components/form/test_slider.py Adds regression coverage for Slider(step=..., min/max=None) scenarios.
vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py Adds regression coverage for RangeSlider(step=..., min/max=None) scenarios.
vizro-core/docs/pages/explanation/authors.md Adds a contributor to the authors list.
vizro-core/changelog.d/20260818_164803_winklemad.md Adds a changelog entry for the fixed TypeError case.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@petar-qb petar-qb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing fix @winklemad! 🚀 Thank you for your contribution.

@petar-qb
petar-qb merged commit 8daaa0d into mckinsey:main Aug 20, 2026
55 of 56 checks passed
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.

3 participants