AlfHou / hammond

Self hosted vehicle and expense management system. Like Clarkson, but better
GNU Affero General Public License v3.0
143 stars 19 forks source link

TimeZone variable seems to be undefined when importing #80

Closed vKnmnn closed 10 months ago

vKnmnn commented 1 year ago

running latest docker i experience issues upon using the generic import function

The parsing of the date fields fails with this error:

2023/09/18 22:21:17 [Recovery] 2023/09/18 - 22:21:17 panic recovered:
time: missing Location in call to Date
/usr/local/go/src/time/time.go:1469 (0x4cea48)
/usr/local/go/src/time/format.go:1398 (0x4c896b)
/usr/local/go/src/time/format.go:1029 (0x4c672a)
/api/service/genericImportService.go:15 (0x97621e)
/api/service/importService.go:125 (0x977536)
/api/controllers/import.go:68 (0x97dbe9)
....

it’s hard to find a description on how the csv fields have to be coded. I have this as a date field: "2023-09-15T14:28:00.000Z" as have found that format in the code. It doesn’t look like that causes the problem here tough. Occurs in firefox and chromium

alienp4nda commented 1 year ago

Open up a web console in your browser and see what the output is for Intl.DateTimeFormat().resolvedOptions().timeZone

That's how the timezone location is grabbed prior to importing.

vKnmnn commented 1 year ago

That gives me "Europe/Oslo" My Computer is set to Europe/Berlin

vKnmnn commented 1 year ago

What else can I do to find out what's causing this?

alienp4nda commented 1 year ago

Open your browser developer tools and select the network tab. Navigate to the generic import and then fill out the form, but don't submit just yet. In the developer window clear the network logs, it makes it way easier to find the request. Now click submit and look for the request to generic and look at the payload. Make sure the timezone key is set to your timezone and is not undefined.

hammond_web_dev

gabbla commented 1 year ago

I'm facing the same issue. The timezone is set accordingly when sending the request:

image

The docker logs:

2023/11/02 09:19:02 /api/service/userService.go:29
[6.220ms] [rows:1] SELECT * FROM `users` WHERE `ID` = "5b82e6cb-9990-468b-b828-298e33565a89" ORDER BY `users`.`id` LIMIT 1

2023/11/02 09:19:02 [Recovery] 2023/11/02 - 09:19:02 panic recovered:
time: missing Location in call to Date
/usr/local/go/src/time/time.go:1469 (0xea253)
/usr/local/go/src/time/format.go:1398 (0xe1fef)
/usr/local/go/src/time/format.go:1029 (0xe00d3)
/api/service/genericImportService.go:15 (0x592dfb)
[GIN] 2023/11/02 - 09:19:02 | 500 |   18.875575ms |   192.168.1.150 | POST     "/api/import/generic"
/api/service/importService.go:125 (0x593feb)
/api/controllers/import.go:68 (0x59accf)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:165 (0x56f3e3)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/recovery.go:99 (0x56f3c0)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:165 (0x5a9557)
/api/main.go:69 (0x5a9530)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:165 (0x56f3e3)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/recovery.go:99 (0x56f3c0)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:165 (0x56e5b7)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/logger.go:241 (0x56e594)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:165 (0x56d53b)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/gin.go:489 (0x56d254)
/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/gin.go:445 (0x56ce2f)
/usr/local/go/src/net/http/server.go:2936 (0x2e7fbf)
/usr/local/go/src/net/http/server.go:1995 (0x2e3747)
/usr/local/go/src/runtime/asm_arm.s:831 (0x866b7)

The dataset I'm currently testing

ID,Data,DataOk,Anno,MeseID,Mese,Litri,Euro/l,Totale,Km,Distributore,Delta,Euro/km,partial
1,02-01-20,2020-01-02T00:00:00.000Z,2020,1,gennaio,53.2,1.399,74.17,0,Auchan,0,,1
vKnmnn commented 11 months ago

bump

alienp4nda commented 11 months ago

I'll be looking into this issue this month.

@vKnmnn and @gabbla what version of the docker image are y'all running? I'd like to do my best to replicate the issue.

alienp4nda commented 11 months ago

The issue seems to be with the docker build using alpine. I have to do more testing to pinpoint the issue.

gabbla commented 11 months ago

I'll be looking into this issue this month.

@vKnmnn and @gabbla what version of the docker image are y'all running? I'd like to do my best to replicate the issue.

Thank you very much. Right now I do not have access to host which was running the docker, sorry. It was foolish me to not include the version, sorry.

alienp4nda commented 11 months ago

@gabbla No worries, I figured out what the issue was with the docker image. The alpine image that is used doesn't have the tzdata (timezone data) package installed. I'll be making a PR right now.

gabbla commented 11 months ago

Nice catch, thank you!

alienp4nda commented 10 months ago

@vKnmnn and @gabbla a new image is out with the fix, multiple people have tested stating it's now working.

gabbla commented 10 months ago

Just tested the latest image, working fine for me too! Thanks!

alienp4nda commented 10 months ago

@gabbla thanks for testing it.