martin-ueding / geo-activity-playground

Data analysis and visualization based on GPS tracked outdoor activities.
https://martin-ueding.github.io/geo-activity-playground/
MIT License
38 stars 14 forks source link

Error in FIT-File that has been generated by another user #153

Closed eifelkiwi closed 3 weeks ago

eifelkiwi commented 2 months ago

Strava lets people add other people to their tour if they did not track the activity themselves. I have such an activity, that I did not track myself. In Strava Export, this generates a FIT-file (which is not compressed as .gz like all the others, but is there as original file).

When running the script, this produces an error: 2024-08-29_fit-import-error.txt This is the file in question (zipped for upload): 11987227538.zip And this is the corresponding metadata in the activities.csv: 2024-08-29_fit-import-error-metadata.csv

One thing to note: the script continues to run and the webserver starts, but the activity does not appear.

martin-ueding commented 1 month ago

The file seems to be corrupted. This is what a FIT file from my Garmin device looks like in the hex editor:

00000000: 0e10 7a08 19f8 0000 2e46 4954 9ee7 4000  ..z......FIT..@.
00000010: 0000 0007 0304 8c04 0486 0704 8601 0284  ................
00000020: 0202 8405 0284 0001 0000 f4f2 f1c9 548d  ..............T.
00000030: f73c ffff ffff 0100 100e ffff 0441 0000  .<...........A..
00000040: 3100 0302 1407 0002 8401 0102 0100 0000  1...............
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 004a 01ff 4200 0020 0104 fd04 8602 0284  .J..B.. ........
00000070: 0001 0101 0101 0253 8df7 3c18 0410 3243  .......S..<...2C

So this is a binary file that happens to contain the ASCII "FIT" in there.

Your file looks like this:

00000000: 5b22 5c78 3045 205c 7838 4452 5c78 4230  ["\x0E \x8DR\xB0
00000010: 5c78 3935 5c78 3030 5c78 3030 2e46 4954  \x95\x00\x00.FIT
00000020: 215c 7838 3940 5c78 3030 5c78 3031 5c78  !\x89@\x00\x01\x
00000030: 3030 5c78 3030 5c78 3035 5c78 3030 5c78  00\x00\x05\x00\x
00000040: 3031 5c78 3030 5c78 3031 5c78 3032 5c78  01\x00\x01\x02\x
00000050: 3834 5c78 3032 5c78 3032 5c78 3834 5c78  84\x02\x02\x84\x
00000060: 3033 5c78 3034 5c78 3843 5c78 3034 5c78  03\x04\x8C\x04\x
00000070: 3034 5c78 3836 5c78 3030 5c78 3034 5c78  04\x86\x00\x04\x
00000080: 3030 5c78 3031 5c78 3046 5c78 4446 5c78  00\x01\x0F\xDF\x
00000090: 4344 5c78 4233 5c78 4345 4741 5c78 3036  CD\xB3\xCEGA\x06

So it is a text file. It looks a bit like it was binary but then encoded with escapes. Also the [" looks like JSON. One can also make out the string "FIT" at the end of the first line.

But loading that with Python's JSON it fails:

json.decoder.JSONDecodeError: Invalid \escape: line 1 column 3 (char 2)

I'm sorry, but I think that file is just weirdly corrupted. I don't think that I can easily recover this.