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

Transient Session Token Errors #295

Open
cassidysymons opened this issue Nov 8, 2023 · 3 comments
Open

Transient Session Token Errors #295

cassidysymons opened this issue Nov 8, 2023 · 3 comments

Comments

@cassidysymons
Copy link
Collaborator

Since re-launch, I've observed a few instances of transient exceptions where the "token" key doesn't exist in the session scope. My initial suspicion was it was a situation where browsers were left open, sessions expired, and there was some scenario where the expiration wasn't handled gracefully. However, there was an error yesterday where the participant was actively using the system, the exception occurred, then they went on using the system successfully.

  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 2196, in get_reconsent
    need_reconsent = check_current_consent(
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3557, in check_current_consent
    has_error, consent_required, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3618, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'

The exception has occurred on a few different paths - registering an FFQ, reconsenting, and viewing a signed consent - so it doesn't seem to be a path-specific issue. This is not high-urgency, as in all instances, the users have been able to continue using the system. However, I plan to look into potential causes and resolution after clearing the list of development tasks necessary for hard launch.

@ayobi
Copy link
Contributor

ayobi commented Jan 17, 2024

Looking into this a little @cassidysymons and yeah I see in the implementation that the token can expire before the session when page is left open.

if has_session:
try:
# If user leaves the page open, the token can expire before the
# session, so if our token goes back we need to force them to login
# again.
email, email_verified = _parse_jwt(session[TOKEN_KEY_NAME])
except jwt.exceptions.ExpiredSignatureError:
return redirect('/logout')

I'm curious what the participant was exactly doing to cause this? Maybe there's a part where the token isn't being set in the session?

You said were able to recreate this error on few different paths?

@cassidysymons
Copy link
Collaborator Author

@ayobi I haven't been able to recreate it, but I haven't actively tried to recreate it yet. The interesting thing is that in these cases, the user isn't being logged out, they're hitting code that expects the token to be there and it's not. Below, I've copied all of the tracebacks from the log where this happened, which perhaps might provide a hint of where to look next. I redacted unique account/source IDs from the log entries but they're irrelevant to the errors.

One other point that I'm not sure is causative or correlative is that this doesn't seem to have happened before the 2023.8 release. We changed a lot of code with that release and I know we expanded our usage of the session scope, but I didn't observe this error during testing on our staging server before the release (but it's a transient and infrequent error, so not observing it doesn't mean much).

[2023-09-11 21:21:09 -0700] [20854] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/consents/data/view [GET]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/microsetta_interface/implementation.py", line 2050, in get_consent_view
    has_error, source_output, _ = ApiRequest.get(
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/microsetta_interface/implementation.py", line 3478, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2023-10-02 06:02:18 -0700] [23675] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/register_ffq [POST]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 184, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 1524, in post_generate_vioscreen_url
    need_reconsent = check_current_consent(account_id, source_id, "data")
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 3511, in check_current_consent
    has_error, consent_required, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 3572, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2023-10-15 08:10:16 -0700] [23671] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/register_ffq [POST]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 184, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 1524, in post_generate_vioscreen_url
    need_reconsent = check_current_consent(account_id, source_id, "data")
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 3511, in check_current_consent
    has_error, consent_required, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.9.3/microsetta_interface/implementation.py", line 3572, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2023-11-07 09:04:14 -0800] [26360] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/reconsent/biospecimen [GET]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 2196, in get_reconsent
    need_reconsent = check_current_consent(
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3557, in check_current_consent
    has_error, consent_required, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3618, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2023-11-10 05:47:31 -0800] [13107] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/register_ffq [POST]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 184, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 1519, in post_generate_vioscreen_url
    need_reconsent = check_current_consent(account_id, source_id, "data")
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3557, in check_current_consent
    has_error, consent_required, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.10/microsetta_interface/implementation.py", line 3618, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2024-01-12 07:14:13 -0800] [17198] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/consents/data/view [GET]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.12/microsetta_interface/implementation.py", line 2218, in get_consent_view
    has_error, source_output, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.12/microsetta_interface/implementation.py", line 3740, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'
[2024-01-12 07:14:13 -0800] [17195] [ERROR] Exception on /accounts/[REDACTED]/sources/[REDACTED]/consents/data/view [GET]
Traceback (most recent call last):
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/produces.py", line 38, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/Users/api_user/microsetta-interface-2023.12/microsetta_interface/implementation.py", line 2218, in get_consent_view
    has_error, source_output, _ = ApiRequest.get(
  File "/Users/api_user/microsetta-interface-2023.12/microsetta_interface/implementation.py", line 3740, in get
    auth=BearerAuth(session[TOKEN_KEY_NAME]),
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/werkzeug/local.py", line 377, in <lambda>
    __getitem__ = lambda x, i: x._get_current_object()[i]
  File "/Users/api_user/miniconda3/envs/microsetta-interface/lib/python3.8/site-packages/flask/sessions.py", line 84, in __getitem__
    return super(SecureCookieSession, self).__getitem__(key)
KeyError: 'token'

@ayobi
Copy link
Contributor

ayobi commented Jan 19, 2024

Ah ok, this was a good exercise to get more familiar with the code base. I looked through some of the changes and see that there's some additions that look like they're attached to some of the filepaths that are in the logs you added. I know you mentioned it might not be the filepath but I found it curious that all the logs mention filepaths that had new code in the new release.

Two that jump out that I've noticed additions/changes on are the ffq and the consent/reconsent.

def get_ajax_check_ffq_code(ffq_code):
try:
response = requests.get(
ApiRequest.API_URL + '/check_ffq_code',
auth=BearerAuth(session[TOKEN_KEY_NAME]),
verify=ApiRequest.CAfile,
params=ApiRequest.build_params({'ffq_code': ffq_code})
)
if response.status_code == 200:
return_val = True
else:
return_val = False
except: # noqa
return_val = False
return return_val

@prerequisite([ACCT_PREREQS_MET])
def get_account(*, account_id=None):
has_error, account, _ = ApiRequest.get('/accounts/%s' % account_id)
if has_error:
return account
has_error, sources, _ = ApiRequest.get('/accounts/%s/sources' % account_id)
if has_error:
return sources
# Update their language preferences cookie whenever they load this page.
# So if changed from another browser/tab/computer,
# going home will reset language
session[LANG_KEY] = account["language"]
# if the user chooses to go back from source detail to
# account overview, source id must be cleared from the
# session
if SOURCE_ID in session:
session.pop(SOURCE_ID)
# also remove the reconsent_declined variable from the session scope
if RECONSENT_DECLINED_KEY in session:
session.pop(RECONSENT_DECLINED_KEY)

I'll continue playing but it may take some time to truly diagnose the issue.

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

No branches or pull requests

2 participants