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
Inconsistencies between return types on different Client methods #48
Comments
Well it should give an error when the ID of the user is invalid or does not exists |
I edited this issue with proper information - sorry for posting it too early! |
This solution probably isn't ideal since it probably is slower than the other events, but if you was to go ahead with it you could maintain backwards compatibility by doing something like def get_user_by_username(username):
return get_users_by_username(username)[0] I personally thing the 3rd one (Create custom errors) will probably be the ideal solution, but make sure to mark the release as a major release so people know it has breaking changes. |
There is no speed factor here.
This wouldn't help because it just creates another issue - now we have a method that raises an IndexError when the ID is invalid rather than returning None, which would break compatibility regardless. Retaining compatibility is not possible here. |
Why don't you just error if get_user_by_username has no values in it and then just give a custom not found error |
It already raises an error when no value is passed. I outlined the issues with a custom NotFound error in the first post. |
Roblox endpoints that take in a single ID, like
users.roblox.com/v1/users/{userId}
, usually raise errors when the passed ID is invalid or does not exist. For example,/v1/users/{userId}
returns the following data and a 404 error when an invalid user ID is passed:In ro.py, this means we can raise a
NotFound
error:Endpoints that take in multiple user IDs, like
games.roblox.com/v1/games/multiget-place-details
, tend to ignore invalid IDs and don't raise errors if none of the IDs are valid. In ro.py, all of ourget_PLURAL
functions likeget_places
andget_universes
maintain this behavior and do not raise errors for invalid IDs.The issue is that not all of our
get_SINGULAR
functions use endpoints that only take in one ID.multiget-place-details
is the only endpoint ro.py uses for places. Because it does not raise an error,get_place
returnsNone
if the place is invalid and doesn't raise an exception. Multiple other methods also have this behavior.This causes an inconsistency between methods where some methods (the ones that send requests that take just one ID) raise errors with invalid inputs, but other methods (the ones that take multiple IDs but only pass one) don't raise errors.
The following
Client
methods all return None with invalid IDs:All other singular methods raise exceptions for invalid IDs.
This causes an inconsistency between methods. What should we do?
We have a couple options here:
None
instead of raising exceptionsNotFound
errors on these methods in particularNotFound
for actual 404 errors.UserNotFound
that are raised in place ofNotFound
onget_user
andget_user_by_username
, and do the same for other methodsNotFound
onget_user
anymore, which is breaking.HTTPException
kind of breaks the rules because it's really only for 4xx/5xx HTTP status codes, not for other purposes.RobloxException
means we're not raising the right exception forget_user
anymore. That's an actual HTTP exception, so I think we should keep that there.get_user_by_username
and notget_user
is a bit weird for the developer because there's an exception calledUserNotFound
that isn't raised on the method used to get users but is raised on the method used to get users by username.get_user_by_username
,get_universe
,get_place
andget_plugin
and force developers to use their plural counterparts:get_users_by_username
,get_universes
,get_places
andget_plugins
.The text was updated successfully, but these errors were encountered: