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

Intermittent NetworkError caused by TypeError in verification Lambda #8

Open
athewsey opened this issue Sep 2, 2021 · 5 comments
Open

Comments

@athewsey
Copy link

athewsey commented Sep 2, 2021

Hi folks,

I've been seeing an intermittent issue which manifests as NetworkError in the front end, but the underlying cause seems to be an unhandled exception in the verification Lambda (because CORS headers don't get set on the error response through API Gateway, so the issue appears as a CORS/network issue on browser side).

Stack trace below but I haven't had chance to dig in to it yet - I wonder if there's something about the number of frames uploaded for the check that can affect the dimensionality of the variable in question?

[ERROR] TypeError: only size-1 arrays can be converted to Python scalars
Traceback (most recent call last):
  File "/var/task/app.py", line 52, in lambda_handler
    status_code, response = execute_if_token_is_valid(body['token'], challenge_id, verify_challenge, challenge_id)
  File "/var/task/app.py", line 68, in execute_if_token_is_valid
    return func(*args)
  File "/var/task/app.py", line 143, in verify_challenge
    state_manager.process(frame)
  File "/var/task/states/manager.py", line 19, in process
    success = self.current_state.process(frame)
  File "/var/task/states/nose.py", line 66, in process
    verified = self.verify_challenge(rek_landmarks, rek_pose, self.challenge_in_the_right)
  File "/var/task/states/nose.py", line 92, in verify_challenge
    trajectory_error = math.sqrt(residuals/len(self.nose_trajectory))
@rafaelwmartins
Copy link
Contributor

Hi. Yes, you're right regarding why errors manifest as NetworkError. That needs to be fixed although is not as important as the underlying error, which is totally unexpected and should never happen. We'll take a look on that exception soon. Thanks for the details.

@helbertDev3c
Copy link

I am facing the same problem, how can it be solved?

@eddturtle
Copy link

I appreciate this might not be that useful, but I think the issue lies in nose.py inside function verify_challenge().

The math sqrt() function only takes in 2 variables, residuals and nose_trajectory - so it has to be in one of those 2. And I think nose_trajectory is ok, so I'm wondering if residuals could be an empty array of some kind?

@eddturtle
Copy link

Based on the info here: https://stackoverflow.com/a/26438018/402585

It does seem to work if you change the code in nose.py verify_challenge() to:

_, residuals, _, _, _ = np.polyfit(nose_trajectory_x, nose_trajectory_y, 2, full=True)

# if empty array, set to zero
if not residuals:
    residuals = 0

trajectory_error = math.sqrt(residuals/len(self.nose_trajectory))

@rznadri
Copy link

rznadri commented Dec 9, 2021

I ran to this issue and the change suggested by @eddturtle fixed 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

5 participants