fix(rotor): surface UnauthorizedError on /rotor/session/* as LoginFailed#120
Merged
fix(rotor): surface UnauthorizedError on /rotor/session/* as LoginFailed#120
Conversation
Copilot review on music-assistant/server#3606 flagged that _rotor_session_request didn't handle UnauthorizedError. An expired or invalidated token during browse / play would let the raw yandex_music exception bubble up through the provider and crash the caller instead of triggering MA's re-auth prompt. Catch it on the outer wrapper (after _call_with_retry / _call_no_retry have done their jobs) and re-raise as LoginFailed, mirroring what connect() already does on initial auth. BadRequestError and NetworkError handling are unchanged. Test: new test_rotor_session_request_maps_unauthorized_to_login_failed stubs the underlying client's _request.post to raise UnauthorizedError and asserts LoginFailed surfaces at the public API. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Addresses Copilot review comment on music-assistant/server#3606 against the upstream sync of v3.4.0.
Problem
`_rotor_session_request` caught `NetworkError` and `BadRequestError` but not `UnauthorizedError`. An expired or invalidated token hitting `/rotor/session/new`, `/tracks` or `/feedback` during normal browse / play would let the raw `yandex_music.exceptions.UnauthorizedError` bubble up through the provider and crash the caller, instead of triggering MA's re-auth prompt.
Fix
Catch `UnauthorizedError` on the outer wrapper (after `_call_with_retry` / `_call_no_retry` have run) and re-raise as `LoginFailed`, mirroring what `connect()` already does on initial auth. `BadRequestError` stays terminal (swallowed), `NetworkError` still propagates to the retry wrapper when `with_retry=True`.
Test plan