fastenhealth / fasten-onprem

Fasten is an open-source, self-hosted, personal/family electronic medical record aggregator, designed to integrate with 100,000's of insurances/hospitals/clinics
GNU General Public License v3.0
1.52k stars 81 forks source link

[Bug]: Record not found #504

Closed rbrowning85 closed 2 weeks ago

rbrowning85 commented 3 weeks ago

Contact Details

What happened?

I performed an update to the pull the newest docker container. When I tried to log back in, it had lost my user account, so i created a new one. However, I keep getting the error shown in the logs. (Note: I redacted the username and IP address)

Flavor

Docker

Version

main

Relevant log output

o888o                       o8                          
o888oo ooooooo    oooooooo8 o888oo ooooooooo8 oo oooooo   
 888   ooooo888  888ooooooo  888  888oooooo8   888   888  
 888 888    888          888 888  888          888   888  
o888o 88ooo88 8o 88oooooo88   888o  88oooo888 o888o o888o
github.com/fastenhealth/fasten-onprem         .-1.1.2

Creating event bus instance now.

2024/08/15 13:44:49 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:113 record not found
[18.593ms] [rows:0] SELECT * FROM `users` WHERE `username` = "USERNAME" ORDER BY `users`.`id` LIMIT 1

2024/08/15 13:44:49 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:113 record not found
[33.998ms] [rows:0] SELECT * FROM `users` WHERE `username` = "USERNAME" ORDER BY `users`.`id` LIMIT 1

2024/08/15 13:44:49 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:113 record not found
[47.087ms] [rows:0] SELECT * FROM `users` WHERE `username` = "USERNAME" ORDER BY `users`.`id` LIMIT 1
time="2024-08-15T13:46:04-04:00" level=error msg="An error occurred while listing source credentials could not retrieve current user: record not found" type=web
time="2024-08-15T13:46:04-04:00" level=error msg="IP ADDRESS - 10cc28cc881f [15/Aug/2024:13:46:04 -0400] \"GET /api/secure/source\" 500 17 \"http://192.168.0.83:9090/web/sources\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\" (56ms)" clientIP=IP ADDRESS hostname=10cc28cc881f latency=56 method=GET path=/api/secure/source referer="IP ADDRESS:9090/web/sources" respLength=17 statusCode=500 type=web userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"

2024/08/15 13:46:04 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:113 record not found
[0.262ms] [rows:0] SELECT * FROM `users` WHERE `username` = "USERNAME" ORDER BY `users`.`id` LIMIT 1

2024/08/15 13:46:04 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:113 record not found
[0.159ms] [rows:0] SELECT * FROM `users` WHERE `username` = "USERNAME" ORDER BY `users`.`id` LIMIT 1
time="2024-08-15T13:46:04-04:00" level=error msg="Error #01: could not find user\n" clientIP=IP ADDRESS hostname=10cc28cc881f latency=56 method=GET path=/api/secure/events/stream referer="IP ADDRESS:9090/web/sources" respLength=0 statusCode=200 type=web userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"
dwradcliffe commented 3 weeks ago

I would probably check to make sure the database has the correct user record (and also sources). I use this https://sqlitebrowser.org/. It's possible that your docker setup may not have had the database saved anywhere?

rbrowning85 commented 3 weeks ago

Thanks. I will check tonight. I just used the Unraid app template from IBRACORP.

rbrowning85 commented 2 weeks ago

So you are correct. It appears that the database file isn't being created or saved anywhere. I added a db path to my docker, but I'm not sure how to create the database.

dwradcliffe commented 2 weeks ago

It should create a database file on boot if the file does not exist.

rbrowning85 commented 2 weeks ago

It does not appear to be creating the database file. Here is a copy of the logs. Each time I restart the container, it prompts me to create a new user.

time="2024-08-26T22:33:06-04:00" level=info msg="172.17.0.1 - db7aec5b05dc [26/Aug/2024:22:33:06 -0400] \"POST /api/secure/query\" 200 26 \"http://192.168.0.83:9090/web/dashboard\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\" (1ms)" clientIP=172.17.0.1 hostname=db7aec5b05dc latency=1 method=POST path=/api/secure/query referer="http://192.168.0.83:9090/web/dashboard" respLength=26 statusCode=200 type=web userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"

2024/08/26 22:33:00 /go/src/github.com/fastenhealth/fasten-onprem/backend/pkg/database/gorm_common.go:1011 record not found [0.147ms] [rows:0] SELECT * FROM fhir_patient WHERE fhir_patient.user_id = "5e895ed9-8672-441b-af12-5db5b2bb63a0" AND fhir_patient.source_id = "3a3fc8f9-b4db-4081-af88-483bb2d20982" AND fhir_patient.source_resource_type = "Patient" ORDER BY fhir_patient.id LIMIT 1

time="2024-08-26T22:33:06-04:00" level=info msg="172.17.0.1 - db7aec5b05dc [26/Aug/2024:22:33:06 -0400] \"POST /api/secure/query\" 200 26 \"http://192.168.0.83:9090/web/dashboard\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36\" (2ms)" clientIP=172.17.0.1 hostname=db7aec5b05dc latency=2 method=POST path=/api/secure/query referer="http://192.168.0.83:9090/web/dashboard" respLength=26 statusCode=200 type=web userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"

dwradcliffe commented 2 weeks ago

Just to check, you've got /opt/fasten/db mapped to a volume outside of the container?

rbrowning85 commented 2 weeks ago

Good catch. My mistake. I had /fasten/db mapped, not /opt/fasten/db... It created the database file. I will continue to play with the app tonight after work to make sure everything is working. I appreciate the help and the quick feedback.

AnalogJ commented 2 weeks ago

Hey @rbrowning85 it sounds like @dwradcliffe was able to help you with this issue, I'm going to close it :)