rfcx / arbimon

Ecoacoustic analysis platform empowering conservationists to analyze acoustic data and to derive insights about the ecosystem at scale
https://arbimon.org
Apache License 2.0
4 stars 1 forks source link

User get 500 error when create a new project #1946

Closed koonchaya closed 4 months ago

koonchaya commented 4 months ago

Original post: https://rfcx.slack.com/archives/C03FD1WD02J/p1714588923511519 @carlybatist

User cannot create a new project and got error 500.

Image

When I try to set up a new project I am getting the error "Failed! Request failed with status code 500" I have attached a screenshot as well of what I have actually added to the project in case I have made any mistakes. I also tried with giving the project an end date and I got the same issue.

koonchaya commented 4 months ago

Additional detail from Art investigation It is missing project id from core after the project created.

Image

grindarius commented 4 months ago

I dug up the logs using this expression to find integration/projects route by querying in Loki like this {pod =~ "arbimon-.+"} |= "integration/projects" which find all pods that starts with arbimon- and contains string integration/projects.

I found this log part

SCR-25670502-qocb

This indicates that the failure comes from legacy. After some digging of the logs I found that the error log is

SCR-25670502-qpcp

Which errors from this line of code https://github.com/rfcx/arbimon-legacy/blob/26760f885c5d0ef654479dac72e934cac9c7aafb/app/model/users.js#L611

It turned out there could be some differences between user's email and the token. The user issues the request with email louisa.mamalis@york.ac.uk which is tied to auth0 user id google-oauth2|105159195017878662308. This is valid. You can check it on jwt.io. There are 3 bearer tokens that this user have used to try to create the project. I listed one here because they all have the same value, just a bit difference in time.

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlF6UTROakpHTkRVd01UTTJSVGREUmpRMVFqazROa001UVVFMU1URTJSREl5T1VJME9VRkVOQSJ9.eyJhdXRoMF91c2VyX2lkIjoiZ29vZ2xlLW9hdXRoMnwxMDUxNTkxOTUwMTc4Nzg2NjIzMDgiLCJodHRwczovL3JmY3gub3JnL2FwcF9tZXRhZGF0YSI6eyJhdXRob3JpemF0aW9uIjp7InJvbGVzIjpbImFwcFVzZXIiXX0sImd1aWQiOiI2N2RlN2YzMC1iMzc5LTRmMWEtYjdkYS02YmY1ZmNjZDJmMDciLCJsb2dpbnNOdW1iZXIiOjV9LC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qDFFAm2ZzX6BvvrGzVJ70gZi9YSthWkZqU1GkUzvJfaCf3F0BkAe2OQUtidFajMtdmcC25qp8Hsta24xejK4HQPLc1ooHZUoGzriAFwIA9BJqkIdBWIDILnYDXfVHpAUxUAFiqAgaaH8BkeAmeP5woePhSSwmLUTKmzZn_G10MiA

The email that's associated with the account is louisa.mamalis@york.ac.uk with auth0 id of google-oauth2|105159195017878662308. But on legacy, the addressed auth0 id is already tied to the user with email lcm566@york.ac.uk. I've looked over all 3 databases and found that only insights (arbimon) have both users listed.

data/db insights legacy core
louisa.mamalis@york.ac.uk
lcm566@york.ac.uk

The auth0 id google-oauth2|105159195017878662308 is tied to email lcm566@york.ac.uk and exists on all 3 databases. That causes the error because the data listed inside the json key is not valid when compared to the user tables.

I think a fix is to find source of truth somewhere and change all places to be the same as that one.

grindarius commented 4 months ago

I think it could be related to this https://en.wikipedia.org/wiki/Email_alias

antonyharfield commented 4 months ago

I've merged the two users louisa.mamalis@york.ac.uk and lcm566@york.ac.uk. Her user account is now louisa.mamalis@york.ac.uk. Please tell her to logout and login again with this user and try creating a project.