fit
fit copied to clipboard
Created files are invalid
Problem on Strava
The files created by Encode
are somehow invalid for some platforms. For example, if I upload the newly created file to Strava, it says "The upload contains bad data.".
I tried to debug them by having a valid FIT file (e.g., https://github.com/tormoder/fit/blob/master/testdata/me/activity-small-fenix2-run.fit) and running it through the following simple program:
package main
import (
"bytes"
"encoding/binary"
"log"
"os"
"github.com/tormoder/fit"
)
func main() {
testData, err := os.ReadFile("activity-small-fenix2-run.fit")
if err != nil {
log.Fatalln(err)
}
file, err := fit.Decode(bytes.NewReader(testData))
if err != nil {
log.Fatalln(err)
}
f, err := os.Create("new.fit")
if err != nil {
log.Fatalln(err)
}
defer f.Close()
err = fit.Encode(f, file, binary.LittleEndian)
if err != nil {
log.Fatalln(err)
}
}
Using FitFileViewer
When uploading the new.fit
file to https://www.fitfileviewer.com/, it shows empty data (whereas the original activity-small-fenix2-run.fit
file showed valid content):
Using GPXSee
Weirdly enough, https://www.gpxsee.org/ shows the new.fit
file correctly.
Using RUNALYZE
Analyzing both files with https://runalyze.com/tool/fit-viewer, the main differences seem to be that new.fit
has a lot of enhanced_speed
, enhanced_max_speed
, enhanced_altitude
fields on its laps and records (whereas activity-small-fenix2-run.fit
doesn't have any enhanced_*
fields) and that new.fit
always uses 0
as its local message type index.
Update: I did another test run where I removed the code that generates the enhanced_*
field generation code from this library and even without those, neither Strava nor FitFileViewer would accept the file. So I'm guessing that those aren't the problem.
Using FIT File Tools
I just did another test, uploading the newly created file to https://www.fitfiletools.com/#/remover#remover. There, the shown data seems to be very weird:
I'm thinking, the issue might be that the timestamps are not encoded correctly.
Using Garmin Online FIT Repair Tool
Uploading the new.fit
file to http://garmin.kiesewetter.nl/ yields the following error: Upload status: The file could not be uploaded. The following error occured: Unexpected end of file while parsing Name has occurred. Line 151558, position 9.
.
Thanks for the report.
I'll try to look into this if I have some available time (together with your other PRs), but it may take a while.
Thanks, @tormoder! Is there any way I can support more or any more information you might need?