Stop mistaking macOS resource-fork sidecars for history files - #77
Merged
Conversation
The history-file pattern was tested unanchored against the full ZIP path, so
`__MACOSX/._Streaming_History_Audio_2024_0.json` matched as readily as the real
thing. macOS writes one of those AppleDouble sidecars per entry whenever an
archive is created or re-zipped on a Mac, so the matched file count doubled,
every sidecar failed JSON.parse, and the user was told:
Found 24 audio history file(s) in ZIP.
Skipped "._Streaming_History_Audio_2015-2017_0.json" - its JSON is
malformed or was read incompletely.
Warning: skipped 12 of 24 file(s) - some of your history is missing from
this import.
That last line is simply false. Nothing was missing: all 12 real files parsed.
The reporting path added for genuinely damaged exports did its job and salvaged
the import, which is why this surfaced as noise rather than breakage — but it
buried the real signal it exists to raise, and told users their data was lost
when it wasn't.
Telemetry made the diagnosis unambiguous: `skipped_count` was always exactly
half of `total_files` (12/24, 5/10, 5/10, 5/10), every affected user was on
macOS, and all failures arrived within ~400ms of the parse starting, far too
fast for the mobile memory-exhaustion corruption this path was built for. The
`" Ma"` fragment quoted in the parse errors is the `Mac OS X` marker in the
AppleDouble header.
Matching now anchors to the basename, which excludes the `._` sidecars while
still allowing the export's own subdirectory.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f5423b1e-b316-412a-bade-c28bf90eeb0f
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.
What users were seeing
Every macOS user importing a re-zipped export got this:
Nothing was missing. All 12 of their real files parsed fine.
Cause
UploadStep.vuematched history files with an unanchored pattern tested against the full ZIP path:macOS writes an AppleDouble sidecar —
__MACOSX/._<name>— for every entry when an archive is created or re-zipped on a Mac. Those paths end in.jsonand containStreaming_History_Audio_, so they matched too. There's exactly one per real file, so the count doubled and every sidecar then failedJSON.parse.How the telemetry gave it away
Three tells, none of which fit real corruption:
skipped_countwas exactly half oftotal_files, every time — one sidecar per fileupload.parseJsonfailure in 30 days came from macOSThe
Unexpected token ' ', " Ma"...in the Chrome errors is theMac OS Xmarker inside the AppleDouble header, not export data.Fix
Anchor the match to the basename, which drops the
._sidecars while still allowing the export's own subdirectory:Impact
No data was ever lost — but users were told it was, which is worse than it sounds for a tool whose whole job is moving someone's listening history. It also buried genuine corruption in noise: real damaged-export reports were outnumbered roughly 30:1 by sidecars, and that skip-and-continue path exists precisely to surface the real ones.
Testing
macOS resource-fork sidecars are not mistaken for history filesbuilds a ZIP the way macOS does — two real files plus two__MACOSX/.../._*AppleDouble entries — and asserts 2 files are found, 2 plays imported, and nothing reported as skipped. Verified it fails without the fix (finds 4 files).Import robustnesstests pass.npm run lint:check0 errors,npm run buildclean.