Repository navigation
fix(import): the parsers stop trusting the file and the Hevy API - #350
Merged
Merged
Conversation
Six ways an export file or a Hevy response put something into the store that the app then showed or counted wrongly: - A Hevy exercise whose sets all had nothing measured imported as an entry with no sets. It counted as matched, an unmatched one was added to the Library as your own, and a day with nothing else on it became an empty workout that blocked the real session on a later import, since existing days win in the merge. The exercise is filed only once a set lands in it, a day with no entries is dropped, and the matched, created and "added as your own" figures are built from the ids the parse kept. - A Hevy workout with a null start_time was filed under 1970: new Date(null) is the epoch. localWhen takes only a string now, so the session is skipped and counted like any other bad start. - An Apple Health record with value "." (the pattern allows it) became a NaN weigh-in, and "0" a zero one. Both are skipped, the gate the CSV branch already had. - A Hevy title that is not text reached the stored workout name, which the history list renders as it is. - A Hevy distance that is not a number divided into a NaN speed. - CATEGORY_BP, KM and HEVY_BP were plain objects indexed by text from the file or the API, so a category of "constructor" stored a function as a body part and "__proto__" stored Object.prototype. They have no prototype now. import-csv.hostile.test.js and import-hevy.hostile.test.js feed both parsers malformed and adversarial input: 42 tests, 14 of them fail on the old parsers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Merged and released in v1.3.10, thanks @kurktchiev! https://github.com/DuarteSantos8/openGym/releases/tag/v1.3.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Six ways an export file or a Hevy API response put something in the store that the app then counts or shows wrong. Each one has a test that fails on the old parser.
if (!day.ex.has(id)) day.ex.set(id, [])) has already filed it, so it imports as an entry with no sets. It counts as matched, an unmatched one is added to the Library as "your own", and a day with nothing else on it becomes an empty workout. That empty workout then blocks the real session on a later import, because days already in the history win the merge. The exercise is filed only once a set lands in it, a day with no entries is dropped, and the matched / created / "added as your own" figures are built from the ids the parse kept.new Date(null)is the epoch, so a Hevy workout withstart_time: nullwas filed under 1 January 1970.localWhenaccepts only a string now, and the session is skipped and counted like any other bad start.[\d.]+lets a bare "." through, andparseFloatmakes it a NaN weigh-in; a "0" became a zero one. Both are skipped, which is what the CSV branch below it already did.distance_metersthat is not a number divided into a NaN speed.CATEGORY_BP,KMandHEVY_BPwere plain objects indexed by text from the file or the API. A category ofconstructorstored a function as the body part and__proto__storedObject.prototype. They have no prototype now.The CSV importer files an exercise and pushes its set in the same step, so it never had the empty-entry case.
import-csv.hostile.test.js and import-hevy.hostile.test.js throw malformed and adversarial input at both parsers: wrong types, prototype names, garbage dates, thousands of rows, files that are not exports. 42 tests pass, and 14 of them fail on the old parsers.
The existing import tests still pass (import-csv, import-csv.strong, import-effort, import-hevy, import-match, import-name-bodypart: 90), as do sheets.import-summary and sheets.plan-import-toast (4), history and sync-merge (222).
#312 edits both parsers and merges cleanly with this. #177 edits import-csv.js and already conflicts with main there.
🤖 Generated with Claude Code