Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Remove unneeded contrib.appengine exceptions #533

Merged
merged 1 commit into from
Jul 12, 2016

Conversation

pferate
Copy link
Contributor

@pferate pferate commented Jun 29, 2016

Resolving issue #465.

Possible breaking change, so probably wait to add in next major release.



class InvalidXsrfTokenError(Exception):
class InvalidXsrfTokenError(Error):

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@theacodes
Copy link
Contributor

@nathanielmanistaatgoogle interested to see your thoughts on this breaking change.

class InvalidClientSecretsError(Exception):
"""The client_secrets.json file is malformed or missing required fields."""
class Error(Exception):
"""Base error for this module."""

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@nathanielmanistaatgoogle
Copy link
Contributor

I like the change, mostly. What valid use cases would we be breaking if we were to just incorporate this now? Do we think that developers have written code that catches appengine.InvalidClientSecretsError and does something else in response? Note that without "Raises:" in the constructor's doc string, I'm hesitant to call the raising of the exception part of the API in the first place.

@theacodes
Copy link
Contributor

Do we think that developers have written code that catches appengine.InvalidClientSecretsError and does something else in response?

Probably not, this is likely something experienced when first developing and is uncaught and just manually addressed, if I had to guess. It's not exactly a "recoverable" exception.

I'm hesitant to call the raising of the exception part of the API in the first place.

Same, but even still we'll probably make the next release 3.0.0.

@pferate
Copy link
Contributor Author

pferate commented Jun 30, 2016

After doing some testing, this may not be considered a breaking change after all.

Since we are importing InvalidClientSecretsError in the appengine module it can still be caught as appengine.InvalidClientSecretsError, even though it is really clientsecrets.InvalidClientSecretsError. Unless users are specifically treating them differently (which isn't likely), the change should be fairly transparent.

@theacodes
Copy link
Contributor

Cool. I'll likely make the next release 3.0.0 anyways because of the other changes.

@pferate
Copy link
Contributor Author

pferate commented Jun 30, 2016

clientsecrets.py

class InvalidClientSecretsError(Exception):
    """Main error"""

appengine.py

class InvalidClientSecretsError(Exception):
    """Duplicated error"""

appengine2.py

from clientsecrets import InvalidClientSecretsError
>>> import appengine
>>> appengine.InvalidClientSecretsError
<class 'appengine.InvalidClientSecretsError'>
>>> import appengine2 as appengine
>>> appengine.InvalidClientSecretsError
<class 'clientsecrets.InvalidClientSecretsError'>

@pferate pferate changed the title Remove duplicated InvalidClientSecretsError Remove unneeded contrib.appengine exceptions Jun 30, 2016
@@ -477,15 +469,15 @@ def _parse_state_value(state, user):
user: google.appengine.api.users.User, The current user.

Raises:
InvalidXsrfTokenError: if the XSRF token is invalid.
ValueError: if the XSRF token is invalid.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@pferate pferate force-pushed the issue_465 branch 4 times, most recently from 24621b5 to 03db57e Compare July 11, 2016 17:09
if xsrfutil.validate_token(xsrf_secret_key(), token, user.user_id(),
action_id=uri):
return uri
return

This comment was marked as spam.

This comment was marked as spam.

@pferate
Copy link
Contributor Author

pferate commented Jul 11, 2016

Updated _parse_state_value() to return None for invalid tokens and the uri otherwise

@theacodes
Copy link
Contributor

@nathanielmanistaatgoogle does this look good to merge?

@pferate
Copy link
Contributor Author

pferate commented Jul 12, 2016

Hold on @jonparrott , I need to add in @nathanielmanistaatgoogle's last suggestions. I've been working on moving this to py.test today (you mentioned that at the meetup last month)

* Duplicated InvalidClientSecretsError - Removed
* Internal only InvalidXsrfTokenError - Removed
@pferate
Copy link
Contributor Author

pferate commented Jul 12, 2016

Ok. I amended the commit to include explicitly returning None.

@nathanielmanistaatgoogle
Copy link
Contributor

@jonparrott: to me this now looks ready to merge.

@theacodes
Copy link
Contributor

Woot. Waiting on GodotTravis.

@theacodes theacodes merged commit cd635f4 into googleapis:master Jul 12, 2016
@theacodes
Copy link
Contributor

Thanks, @pferate this is a great change. :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants