Skip to content

docs+test(spotify): add re-auth cycle docs and client-level invalid_grant test - #48409

Closed
aieng-abdullah wants to merge 2 commits into
NousResearch:mainfrom
aieng-abdullah:fold-docs-tests
Closed

docs+test(spotify): add re-auth cycle docs and client-level invalid_grant test#48409
aieng-abdullah wants to merge 2 commits into
NousResearch:mainfrom
aieng-abdullah:fold-docs-tests

Conversation

@aieng-abdullah

@aieng-abdullah aieng-abdullah commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the missing documentation update and client-level test for the Spotify invalid_grant fix in #28155.

  • The docs still claim "you only log in once per machine" — that is no longer true after Spotify's July 20, 2026 refresh token expiry change.
  • There is no test confirming that SpotifyAuthRequiredError surfaces correctly at the client level when invalid_grant is raised from the auth layer.

This PR closes both gaps.

Related Issue

Fixes #48381
Contributes to #28155

Type of Change

  • Documentation update
  • Tests (adding or improving test coverage)

Changes Made

  • website/docs/user-guide/features/spotify.md — removes the "you only log in once per machine" claim and documents the 6-month re-auth cycle
  • tests/tools/test_spotify_client.py — adds a test confirming SpotifyAuthRequiredError is raised with a user-facing message when invalid_grant propagates from the auth layer

How to Test

  1. Run pytest tests/tools/test_spotify_client.py -v and confirm the new test passes
  2. Review website/docs/user-guide/features/spotify.md to confirm the re-auth cycle is accurately documented

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • Tested on: Ubuntu 24.04

Documentation & Housekeeping

  • Updated relevant documentation (website/docs/user-guide/features/spotify.md)
  • cli-config.yaml.example — N/A
  • CONTRIBUTING.md / AGENTS.md — N/A
  • Cross-platform impact — documentation and test only, no platform-specific code
  • Tool descriptions/schemas — N/A

EloquentBrush0x and others added 2 commits May 18, 2026 22:06
resolve_spotify_runtime_credentials() called _refresh_spotify_oauth_state()
without a try/except, so a terminal failure (HTTP 400/401, invalid_grant,
refresh_token_reused) raised AuthError but left the dead refresh_token in
auth.json. Every subsequent session re-read and retried the same token over
the network, failing identically each time.

Fix: wrap the refresh call and, when exc.relogin_required is True and a
refresh_token is present, clear the dead OAuth fields (access_token,
refresh_token, expires_at, expires_in, obtained_at) and write a
last_auth_error quarantine marker to auth.json before re-raising. The next
call sees no access_token and fails fast with spotify_access_token_missing —
no network retry — and the user is prompted to re-authenticate.

Mirrors the quarantine pattern already in place for Nous, xAI-OAuth,
Codex-OAuth (NousResearch#28116, NousResearch#28118), and MiniMax-OAuth (NousResearch#28119).
…valid_grant test

- Remove the 'you only log in once per machine' claim from spotify.md
  and document the ~6-month refresh token expiry with re-auth instructions
- Add test_client_wraps_invalid_grant_as_spotify_auth_required_error to
  confirm SpotifyClient wraps AuthError(code=spotify_refresh_invalid_grant)
  into SpotifyAuthRequiredError with a user-facing message

Refs: NousResearch#28155
@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists labels Jun 18, 2026
@aieng-abdullah aieng-abdullah changed the title Fold docs tests docs+test(spotify): add re-auth cycle docs and client-level invalid_grant test Jun 18, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Bug Fix + Test — Looks Good

  • Correct quarantine pattern: When Spotify OAuth refresh fails with relogin_required=True, dead tokens are now cleared from auth.json so subsequent calls fail fast without retrying a known-bad refresh token. Mirrors the established pattern for Nous, xAI-OAuth, Codex-OAuth, and MiniMax.
  • Correct re-auth state tracking: Stores last_auth_error with structured error metadata so clients can detect and prompt re-auth.
  • Best-effort save: Failed quarantine write is swallowed with debug log (never breaks the main flow).
  • Good test coverage: New tests covering the invalid_grant / quarantined state re-auth cycle.
  • No debug artifacts or secrets

Reviewed by Hermes Agent

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #49944 (docs salvage cluster 2). Your commit was cherry-picked onto current main with your authorship preserved in git log — rebase-merged so it lands under your name. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Spotify refresh tokens expire after 6 months: no re-auth flow on invalid_grant

5 participants