New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple errors thrown on reaching max retries by #580 #581
Comments
Hi @Quizz1Cal, thanks for the nice report. In your opinion would reverting #580 and re-opening #571 help? Also if you feel confident to write a fix for this, that would be really appreciated 🙏 |
In the sense that #580 does not spiritually resolve #571, perhaps a revert would be best. In terms of a fix, I'm basically already there so going the full distance should be fine! It comes down to what you'd want to see in a thrown SpotifyException. I can extract the true url from https://api.spotify.com/{v1/etc...} from the If you approve the PR, would you be willing to label it as hacktoberfest-accepted? (It's not the reason I'm using spotipy, so I'll still fix it regardless :) ) |
I've developed a fix: # ... spotipy/client.py line 267
except requests.exceptions.RetryError as retry_error:
request = retry_error.request
logger.error('Max Retries reached')
try:
reason = retry_error.args[0].reason
except (IndexError, AttributeError):
reason = None
raise SpotifyException(
599,
-1,
"%s:\n %s" % (request.path_url, "Max Retries"),
reason=reason
) I have only attempted action (1) from above; it should be noted that catching the SpotifyException itself here will silence all aforementioned errors. I'm not sure if I should open a PR if you haven't yet reverted #580 , so I figure I'd post the minor change here for now. It passes all tests, though I don't believe we have any tests to deal with this specific issue. Perhaps something to add? |
I reverted #580 in #582 and reopened the initial issue #571. In your PR, feel free to solve both #571 and #581
Definitely!
Your fix looks good, displaying
Yes integration tests might not consistently test this. If you find a way to unit test/mock it, that'd be amazing, otherwise feel free to submit the PR without it. On my side I'll be testing this manually to make sure it's all good. |
NOTE: My first issue to a public repo, any feedback is appreciated :)
Describe the bug
Using spotipy post-#580 (relevant issue #571 ) yields uncaught urllib3 / requests library errors, and in particular an AttributeError due to
retry_error.response
being None (see below). Furthermore, though not featured below, line 274 of client.py under this commit will also throw an AttributeError for the same reason.Your code
Note: Have defined environment variables
SPOTIPY_CLIENT_ID
,SPOTIPY_CLIENT_SECRET
,SPOTIPY_CLIENT_USERNAME
andSPOTIPY_REDIRECT_URI
.Expected behavior
According to the implementation of the
requests
library, responses are expected to not be passed to RetryErrors (see source code here; AFAIK this is the only circumstance it is thrown by the library).Therefore, it is my belief that:
Output
WARNING: Paths modified for privacy
Environment:
The text was updated successfully, but these errors were encountered: