mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#346
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Quizz1Cal on GitHub (Oct 5, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/581
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.responsebeing 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_USERNAMEandSPOTIPY_REDIRECT_URI.Expected behavior
According to the implementation of the
requestslibrary, 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:
18e82b6625(#580 )@stephanebruckert commented on GitHub (Oct 5, 2020):
Hi @Quizz1Cal, thanks for the nice report.
In your opinion would reverting https://github.com/plamere/spotipy/pull/580 and re-opening https://github.com/plamere/spotipy/issues/571 help? Also if you feel confident to write a fix for this, that would be really appreciated 🙏
@Quizz1Cal commented on GitHub (Oct 5, 2020):
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
error.request.url, which I presume would always equal to response.url. Shouldn't be hard to catch the other exceptions, but can you confirm it would be appropriate to catch or otherwise avoid throwing the urllib3 / requests library errors?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 :) )
@Quizz1Cal commented on GitHub (Oct 6, 2020):
I've developed a fix:
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?
@stephanebruckert commented on GitHub (Oct 6, 2020):
I reverted https://github.com/plamere/spotipy/pull/580 in https://github.com/plamere/spotipy/pull/582 and reopened the initial issue https://github.com/plamere/spotipy/issues/571. In your PR, feel free to solve both #571 and #581
Definitely!
Your fix looks good, displaying
retry_error.request.path_urlas part of a SpotifyException totally makes sense.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.
urllib'squoteto encode user ids in urls #307 #860