-
-
Notifications
You must be signed in to change notification settings - Fork 801
Fix: Handle AttributeError in IntrospectTokenView #1562
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
Open
dawidwolski-identt
wants to merge
9
commits into
jazzband:master
Choose a base branch
from
dawidwolski-identt:handle_attribute_error_in_get_token_response
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a97350a
Fix: Handle AttributeError in IntrospectTokenView
dawidwolski-identt d8e7efa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 700264f
Merge branch 'master' into handle_attribute_error_in_get_token_response
dawidwolski-identt d1a5bdf
Merge branch 'master' into handle_attribute_error_in_get_token_response
dawidwolski-identt ad927b6
Return HTTP 400 if no token is provided
dawidwolski-identt c5c7b9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a3f6030
json response
dawidwolski-identt 02884ad
Merge branch 'handle_attribute_error_in_get_token_response' of github…
dawidwolski-identt e35e876
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 if something other than the token raised the attribute error? Is there a way to proactively test the token so we avoid the overhead of exception handling.
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.
I think it would be better to change the error message to be more generic and fix the bug that causes the app to crash. Then, if necessary, specify a message. WDYT?
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.
Is there a way to check if a token was provided before get_token_response is called? Are there existing hooks for validation where this could be caught in advance?
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.
I think it is a proper place to check for the presence of a token. It's the first place where the token is accessed. To move this check one level up, we can use
request.GET.get("token", None)
without a default, but then we need to handle the missing token twice.Uh oh!
There was an error while loading. Please reload this page.
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.
I see both get and post
return self.get_token_response(request.[GET|POST].get("token", None))
Why not check
if token_value is None:
before calculating a checksum, rather than waiting ontoken_value.encode
to raise anAttributeError
and avoid the overhead of handling an exception unnecessarily.