Skip to content
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

Context state keyError Exception message for humans #324

Closed

Conversation

peppelinux
Copy link
Member

This PR introduces a human readable message to Users when they gets SATOSA_BASE KeyError.
Found it usefull to avoid weird Users open assistane tickets when they gets that "ermetic" error on the screen.

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what problem you are trying to solve with this PR?
  • Have you added information on what your changes do and why you chose this as your solution?
  • Have you written new tests for your changes?
  • Does your submission pass tests?
  • This project follows PEP8 style guide. Have you run your code against the 'flake8' linter?

@ioparaskev
Copy link
Contributor

While I'm in favor of a more helpful error message in the logs (or in a FAQ maybe), the current log entry is like it is addressed to the user and not the admin that will look at the error.
In addition to that I think that it's better to handle error pages/redirects outside SATOSA to have less concerns and let the admin customize how they want to handle such cases

p.s: in the current commit while there's a redirect_url, it's not used anywhere

@peppelinux
Copy link
Member Author

Thank you John, you are proof of the existence of life here :')

What we would do to get this job done?
My users now have something clear, a hint and we would also move to a better design, so I agree with you.

Would we instead use a redirect page?
We should specialize another url for this case or reuse a more general one, like I did here:
#325

space for ideas, the integrations are often trivial

Copy link
Member

@c00kiemon5ter c00kiemon5ter left a 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 good to catch such cases or exceptions, but first we should make sure we understand the error, where it comes from and why it is happening. We should not be masking errors that we haven't analysed and made sure that the handling of the error is in the right place.

In this specific case, the state has been created/parsed in a previous step. At which point in the flow do we have enough information to know that the state shouldn't have been empty?
Is this the right place? or is this just the place where the state was accessed and things broke?

@@ -134,6 +134,12 @@ def _auth_resp_callback_func(self, context, internal_response):
"""

context.request = None
context_state = context.state.get(STATE_KEY)
if not context_state:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which are the conditions that make this possible? Why would the state be empty?

Copy link
Member Author

@peppelinux peppelinux Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a superior knowledge that I would gain when I grow up ;)

That's the footprint I collected:
#326 (comment)

Which method do you suggest to do, should we pick all the things with a python debugger or we should move to a big view that let us to satisfy our users without make too much noise in the code. It's a kind of paternalism that we acquire getting older, the users are tring to tell us something ...

Probably you know better than me how and when the context.state became inconsistent. Let's try to talk about this in a separate thread if you agree

@@ -134,6 +134,12 @@ def _auth_resp_callback_func(self, context, internal_response):
"""

context.request = None
context_state = context.state.get(STATE_KEY)
if not context_state:
redirect_url = self.config.get("UNKNOW_ERROR_REDIRECT_PAGE")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed as @ioparaskev mentioned.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ioparaskev @c00kiemon5ter I miss something here, should we really print the things only on the logs and do not redirect users to a informational page?

We could find a transitional solution if you agree, something good for our users and then a following refactor with more design elements in the hands. Let me know, you know my limits, try your best :)

redirect_url = self.config.get("UNKNOW_ERROR_REDIRECT_PAGE")
raise SATOSAStateError(('context.state has no {}. Your session '
'is not valid, please start a new '
'Authentication request again.'.format(STATE_KEY)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is good to catch such cases or exceptions, but first we should make sure we understand the error, where it comes from and why it is happening. Can we change the code to make it as if the error did not happen at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @ioparaskev said, SATOSA is currently not concerned about user-facing messages. This message is a mix of technical ("context.state has no") and user-facing information ("please start a new authentication"). I think that neither part is good. What we want to provide in an exception is not a message, but error context. Which information is useful to understand why this happened? This is the information that the exception should hold. I lean on making this information structured, a dict with meaningful keys and data as values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the PR suggested by @skoranda is the solution for the 60% of this kind of problem, really. I follow the users in their daily abits and many of them use the Disco url to bookmark the SP... That's it.

Scott gave us the remediation here:
#322

Move in that direction, merge that first then come back here with better refactoring. I'm behind you (but with 2 meters of covid-social-distancing!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping here

@c00kiemon5ter
Copy link
Member

closed by d986464

@peppelinux
Copy link
Member Author

See my comment here
#363 (comment)

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

Successfully merging this pull request may close these issues.

3 participants