[PR #689] [MERGED] Fallback on decoding error responses into string if decoding into JSON fails #995

Closed
opened 2026-02-28 00:03:09 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/spotipy-dev/spotipy/pull/689
Author: @Peter-Schorn
Created: 6/10/2021
Status: Merged
Merged: 6/19/2021
Merged by: @stephanebruckert

Base: masterHead: master


📝 Commits (8)

  • 9ebb336 Fixed a bug in the initializers for the auth managers that produced a spurious warning message if you provide a cache handler and you set a value for the "SPOTIPY_CLIENT_USERNAME" environment variable.
  • ffe5f03 fixed a bug in _get_auth_response_local_server which occurs if you provide a state parameter and click cancel in the authorization dialog
  • 3360c9c Fallback on decoding the error response body into text if decoding into JSON fails.
  • fc67526 Fall back on decoding oauth errors into text if decoding into JSON fails.
  • f26b9c4 Merge pull request #1 from plamere/master
  • 631af24 Fixed unused http_error name in exeception clause.
  • e99d11e Updated CHANGELOG
  • 9bddb1f Merge branch 'master' into master

📊 Changes

3 files changed (+121 additions, -113 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 spotipy/client.py (+14 -8)
📝 spotipy/oauth2.py (+106 -105)

📄 Description

In their ultimate wisdom, Spotify decided to return a plain string for some error responses instead of returning one of their documented JSON error objects.

This addresses #688. Instead of

spotipy.exceptions.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/me/:
 error, reason: None

you get

spotipy.exceptions.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/me/player/pause:
 User not approved for app, reason: None

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/spotipy-dev/spotipy/pull/689 **Author:** [@Peter-Schorn](https://github.com/Peter-Schorn) **Created:** 6/10/2021 **Status:** ✅ Merged **Merged:** 6/19/2021 **Merged by:** [@stephanebruckert](https://github.com/stephanebruckert) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (8) - [`9ebb336`](https://github.com/spotipy-dev/spotipy/commit/9ebb33680f7b21a7045ff0aff0bc743de1d9b097) Fixed a bug in the initializers for the auth managers that produced a spurious warning message if you provide a cache handler and you set a value for the "SPOTIPY_CLIENT_USERNAME" environment variable. - [`ffe5f03`](https://github.com/spotipy-dev/spotipy/commit/ffe5f0387305dee41de377c16744a71b4141cf8d) fixed a bug in _get_auth_response_local_server which occurs if you provide a state parameter and click cancel in the authorization dialog - [`3360c9c`](https://github.com/spotipy-dev/spotipy/commit/3360c9c2a54d9417e43d1e61ef6552082a369cfe) Fallback on decoding the error response body into text if decoding into JSON fails. - [`fc67526`](https://github.com/spotipy-dev/spotipy/commit/fc675263b6253253e4229fc7e67ef3c4c235ef40) Fall back on decoding oauth errors into text if decoding into JSON fails. - [`f26b9c4`](https://github.com/spotipy-dev/spotipy/commit/f26b9c44fbb6cf692710c6dc3c4fd4b79f268f51) Merge pull request #1 from plamere/master - [`631af24`](https://github.com/spotipy-dev/spotipy/commit/631af247314a3a9a9df77d6c6c4d50963384ba27) Fixed unused `http_error` name in exeception clause. - [`e99d11e`](https://github.com/spotipy-dev/spotipy/commit/e99d11e19b8a7c96de9d8d27bd1092a4ce9fae55) Updated CHANGELOG - [`9bddb1f`](https://github.com/spotipy-dev/spotipy/commit/9bddb1f3250eff3d6e419163a32c35d63107e7c5) Merge branch 'master' into master ### 📊 Changes **3 files changed** (+121 additions, -113 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `spotipy/client.py` (+14 -8) 📝 `spotipy/oauth2.py` (+106 -105) </details> ### 📄 Description In their ultimate wisdom, Spotify decided to return a plain string for some error responses instead of returning one of their documented JSON error objects. This addresses #688. Instead of ``` spotipy.exceptions.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/me/: error, reason: None ``` you get ``` spotipy.exceptions.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/me/player/pause: User not approved for app, reason: None ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:03:09 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#995
No description provided.