tormoder / fit

A Go package for decoding and encoding Garmin FIT files
MIT License
243 stars 42 forks source link

Coros fit file parsing: validating Event failed #78

Open qdesrame opened 1 year ago

qdesrame commented 1 year ago

Hello, I'm trying to parse a fit files exported from Coros Hub (Coros Apex Pro watch).

I have an error when i'm trying to decode the file: parsing definition message: validating Event failed: field 3: size (1) is less than base type size (4)

Here is the full trace with fit.WithStdLogger() options:

header decoded: size: 14 | protover: 32 | profver: 2178 | dsize: 188025 | dtype: .FIT | crc: 0xc6a5
definition message parsed: local: 0 | global: FileId | arch: LittleEndian | fields: 5 | data dev fields: 0
parsed file_id message: {Activity Coros 841 0 2023-02-05 17:18:37 +0000 UTC 65535 COROS APEX Pro}
definition message parsed: local: 0 | global: DeveloperDataId | arch: LittleEndian | fields: 3 | data dev fields: 0
definition message parsed: local: 0 | global: DeviceInfo | arch: LittleEndian | fields: 3 | data dev fields: 0
definition message parsed: local: 0 | global: Activity | arch: LittleEndian | fields: 7 | data dev fields: 0
definition message parsed: local: 0 | global: FieldDescription | arch: LittleEndian | fields: 5 | data dev fields: 0
definition message parsed: local: 0 | global: FieldDescription | arch: LittleEndian | fields: 5 | data dev fields: 0
definition message parsed: local: 0 | global: FieldDescription | arch: LittleEndian | fields: 5 | data dev fields: 0
definition message parsed: local: 0 | global: FieldDescription | arch: LittleEndian | fields: 5 | data dev fields: 0
definition message parsed: local: 0 | global: Event | arch: LittleEndian | fields: 4 | data dev fields: 0
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 3 | data dev fields: 0
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 5 | data dev fields: 1
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 7 | data dev fields: 1
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 8 | data dev fields: 1
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 9 | data dev fields: 1
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 10 | data dev fields: 1
definition message parsed: local: 0 | global: Record | arch: LittleEndian | fields: 12 | data dev fields: 1
definition message parsed: local: 0 | global: Event | arch: LittleEndian | fields: 4 | data dev fields: 0
illegal definition message: local: 0 | global: Event | arch: LittleEndian | fields: 5 | data dev fields: 0
panic: parsing definition message: validating Event failed: field 3: size (1) is less than base type size (4)

I can provide the .fit file if needed 🙂

qdesrame commented 1 year ago

It seems related to this issue in Golden Cheetah: https://groups.google.com/g/golden-cheetah-developers/c/RVb_fk9kSOM https://github.com/GoldenCheetah/GoldenCheetah/issues/3645

Here is the fix they made: https://github.com/dtcooper/python-fitparse/pull/116

I tried something on my side, it's working now with my fit file but i'm not sure of what I've done 😅

tormoder commented 1 year ago

Hi. Thanks for the links regarding Coros files.

We would need to add a more permissive parsing mode to allow such "bugs".