posit-dev / posit-dev/py-shiny
Add `ValidationException`, similar to `SafeException`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
When a reactive element depends on an input or a specific range of input values, app authors have limited options:
- Use
req(input.foo())to prevent the reactive from running, but this happens silently. - Raise a
SafeExceptiondescribing the problem, but this renders in the client as a red Error: message. - Use a custom UI element as a replacement.
@output
@render.plot
def barchart():
if not len(input.traits()):
raise SafeException("Please select one or more traits.")
if not len(input.breeds()):
raise SafeException("Please select one or more breeds.")
Instead of this process, it would be helpfup if authors could raise a ValidationError that doesn't render as an error. Maybe something like this:
@output
@render.plot
def barchart():
if not len(input.traits()):
raise ValidationException("Please select one or more traits.")
if not len(input.breeds()):
raise ValidationException("Please select one or more breeds.")
Here's an example app that motivated this issue
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing SafeException handling from the issue's reactive output example and compare how its message is rendered in the client. Determine the relevant reactive and output-rendering entry points, then define tests for a ValidationException whose message is shown without the red Error treatment. Done means the new exception behavior supports the input-validation examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100