[fix] improve width/height error message to say "positive integer"#13206
Merged
sfc-gh-lwilby merged 1 commit intodevelopfrom Dec 3, 2025
Merged
[fix] improve width/height error message to say "positive integer"#13206sfc-gh-lwilby merged 1 commit intodevelopfrom
sfc-gh-lwilby merged 1 commit intodevelopfrom
Conversation
Contributor
✅ PR preview is ready!
|
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error message accuracy by updating width/height validation error messages to specify "a positive integer" instead of "an integer", making it clearer that 0 and negative values are not valid.
Key Changes:
- Updated error messages in
StreamlitInvalidWidthError,StreamlitInvalidHeightError, andStreamlitInvalidSizeErrorclasses - Modified 14 test files to use substring matching (
in) instead of exact string matching for error message validation
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/streamlit/errors.py | Updated error message text in three exception classes to say "a positive integer (pixels)" instead of "an integer (pixels)" |
| lib/tests/streamlit/spinner_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/text_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/radio_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/pyplot_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/metric_test.py | Updated test assertions for both height and width validation to use substring matching |
| lib/tests/streamlit/elements/markdown_test.py | Updated test assertions for markdown, caption, and badge functions to use substring matching |
| lib/tests/streamlit/elements/image_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/html_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/heading_test.py | Updated test assertions for header, subheader, and title functions to use substring matching |
| lib/tests/streamlit/elements/color_picker_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/checkbox_test.py | Updated test assertions for both checkbox and toggle functions to use substring matching |
| lib/tests/streamlit/elements/button_group_test.py | Updated test assertions to use substring matching and updated expected error message text |
| lib/tests/streamlit/elements/alert_test.py | Updated test assertions to use substring matching with proper multi-line formatting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Fixes #12868
Updates the error message for invalid
widthandheightvalues to say "a positive integer" instead of "an integer". This makes the error message more accurate since 0 and negative values are not valid.Before:
After:
Changes
StreamlitInvalidWidthErrorinerrors.pyto say "a positive integer (pixels)"StreamlitInvalidHeightErrorinerrors.pyto say "a positive integer (pixels)"StreamlitInvalidSizeErrorinerrors.pyto say "a positive integer (pixels)"GitHub Issue Link (if applicable)
Closes #12868
Testing Plan
in) to check for the key part of the error message.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.