Skip to content

Raise a RadioBrowserValidationError for invalid arguments - #1602

Merged
frenck merged 1 commit into
mainfrom
frenck/validation-error
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/validation-error

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

None compared to the last release (0.3.2). Invalid arguments raised a ValueError there, and RadioBrowserValidationError is a ValueError, so except ValueError keeps working.

Compared to main, it undoes most of the breaking change of #1597: code that catches probatio.Invalid around radios calls should catch RadioBrowserValidationError (or RadioBrowserError) instead. The probatio error is still reachable as __cause__.

Proposed change

Since #1597, an invalid argument raised probatio's Invalid. That meant a caller needed a second except next to RadioBrowserError, and an except ValueError written against an earlier release silently stopped catching it.

probatio 0.13.0 lets the decorator raise an error of our own (frenck/probatio#437). This adds:

class RadioBrowserValidationError(RadioBrowserError, ValueError):
    """Radio Browser exception for an invalid argument, raised before a request."""

Every public method uses @probatio(error=RadioBrowserValidationError), and the checks that span several arguments (a location that is incomplete, filter_by without a filter_term) raise it themselves. One except RadioBrowserError now covers everything the library raises, and the message still names the argument:

radios.exceptions.RadioBrowserValidationError: value must be at least 0 at 'limit'

The minimum probatio version goes to 0.13.0. Home Assistant pins 0.12.5 today, so the Home Assistant PR that bumps radios needs to bump probatio as well. The README, the docstrings and AGENTS.md describe the new error.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

Invalid arguments raised probatio's Invalid, so a caller needed a second
except next to RadioBrowserError, and an except ValueError from before
1.0 no longer worked. probatio 0.13.0 lets the decorator raise an error
of our own, so raise a RadioBrowserValidationError, which is a
RadioBrowserError and a ValueError. The probatio error stays reachable
as its cause.
@frenck frenck added the new-feature New features or options. label Oct 2, 2026
@frenck
frenck merged commit eaa22d7 into main Oct 2, 2026
31 checks passed
@frenck
frenck deleted the frenck/validation-error branch October 2, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant