-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix authentication error payload #360
Conversation
) | ||
except Exception as ex: | ||
assert ex.__class__ == BadRequestException | ||
|
||
def test_bad_request_exceptions_exclude_expected_request_data(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we want is for everything in the return value to be added to exceptions, this test does the opposite.
workos/exceptions.py
Outdated
def __str__(self) -> str: | ||
message = self.message or "No message" | ||
exception = "(message=%s" % message | ||
self.message = self.extractFromJson("message", "No message") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is 100x nicer than except ValueError
, good stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Also lol snake case
workos/exceptions.py
Outdated
self.error = self.extractFromJson("error", None) | ||
self.errors = self.extractFromJson("errors", None) | ||
self.code = self.extractFromJson("code", None) | ||
self.error_description = self.extractFromJson("error_description", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error
and error_description
previously defaulted to "Unknown"
so this is a small change in behavior (line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch!
thank you! |
Description
Exceptions were only returning specific hardcoded values, which isn't accurate any more since an error can have a plethora of parameters in it.
This fixes it by dumping the contents of the API response into the error object, giving the user all the information they need to fix the error.
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.