Closed ElliotKillick closed 1 year ago
This is likely something we will not support. An empty list is different from not enabled. An empty list means that the subreddit has none while 403 means it is explicitly disabled.
I'm not sure the specifics of the API and so forth. However, returning empty or None
is often preferable to raising exceptions (especially when their meaning is ambiguous because a 403 could, for example, also mean the subreddit is private).
I also found that it violates POLS/POLA
PRAW rarely catches exceptions for the end user. The only instances I can think of when stickying, partial_redditors, and submitting media. In all of these instances PRAW does something in response to the exception. As such, this should be handled in the user's code. In this instance a 403 has a meaning: you're not allowed to get the user selectable flairs. I think the reason why Reddit raises a 403 instead of returning an empty list is because a subreddit can still have user selectable flairs populated but has the option to actually allow the user to select them disabled. I understand it is preferable to not raise an exception, but the exception is originating from the API and not PRAW.
I also found that it violates POLS/POLA
This is an issue with Reddit's API. Their API has many surprises and PRAW tries its best to handle these for you but at times this is futile.
Describe the Bug
r/software has flairs configured as unavailable: https://www.reddit.com/r/software/submit
Trying to enumerate flairs with PRAW under this condition causes a 403. I can grab the flairs for other subreddits just fine so this does appear to be the root cause.
Desired Result
Cleanly return an empty generator. No exception raised.
Code to reproduce the bug
The
Reddit()
initialization in my code example does not include the following parameters to prevent credential leakage:client_secret
,password
, orrefresh_token
.Relevant Logs
This code has previously worked as intended.
No
Operating System/Environment
GNU/Linux
Python Version
3.11.4
PRAW Version
7.7.1
Prawcore Version
2.3.0
Anything else?
Thank you for making PRAW, it's a great piece of software!