Skip to content

fix(rotor): surface UnauthorizedError on /rotor/session/* as LoginFailed#120

Merged
trudenboy merged 2 commits intodevfrom
fix/rotor-session-unauthorized
Apr 23, 2026
Merged

fix(rotor): surface UnauthorizedError on /rotor/session/* as LoginFailed#120
trudenboy merged 2 commits intodevfrom
fix/rotor-session-unauthorized

Conversation

@trudenboy
Copy link
Copy Markdown
Owner

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

  • New `test_rotor_session_request_maps_unauthorized_to_login_failed` — stubs the underlying MarshalX client's `_request.post` to raise `UnauthorizedError`, asserts `LoginFailed` at the public API.
  • `pytest` — 256/256 green.
  • `ruff` / `mypy` — clean.

trudenboy and others added 2 commits April 23, 2026 17:55
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>
@trudenboy trudenboy merged commit c08adfa into dev Apr 23, 2026
5 checks passed
@trudenboy trudenboy deleted the fix/rotor-session-unauthorized branch April 23, 2026 15:34
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.

1 participant