Skip to content

Stop mistaking macOS resource-fork sidecars for history files - #77

Merged
taurheim merged 1 commit into
masterfrom
fix/macos-resource-fork-files
Aug 7, 2026
Merged

Stop mistaking macOS resource-fork sidecars for history files#77
taurheim merged 1 commit into
masterfrom
fix/macos-resource-fork-files

Conversation

@taurheim

@taurheim taurheim commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What users were seeing

Every macOS user importing a re-zipped export got this:

Found 24 audio history file(s) in ZIP.
Skipped "._Streaming_History_Audio_2015-2017_0.json" — its JSON is malformed or was read incompletely.
… ×12 …
Warning: skipped 12 of 24 file(s) — some of your history is missing from this import.

Nothing was missing. All 12 of their real files parsed fine.

Cause

UploadStep.vue matched history files with an unanchored pattern tested against the full ZIP path:

const audioFilePattern = /Streaming_History_Audio_.*\.json$/;

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 .json and contain Streaming_History_Audio_, so they matched too. There's exactly one per real file, so the count doubled and every sidecar then failed JSON.parse.

true  Streaming_History_Audio_2015-2017_0.json
true  __MACOSX/._Streaming_History_Audio_2015-2017_0.json   ← should be false

How the telemetry gave it away

user OS skipped / total
laurenvickers_ Mac OS X 12 / 24
stupidemorat Mac OS X 5 / 10
falintouden Mac OS X 5 / 10
goopy_monkey Mac OS X 5 / 10

Three tells, none of which fit real corruption:

  1. skipped_count was exactly half of total_files, every time — one sidecar per file
  2. Every clustered upload.parseJson failure in 30 days came from macOS
  3. All 12 of laurenvickers_'s failures landed within 435ms of the parse starting — far too fast for the mobile memory-exhaustion case this path was built for

The Unexpected token ' ', " Ma"... in the Chrome errors is the Mac OS X marker 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:

const audioFilePattern = /^Streaming_History_Audio_.*\.json$/;
const matchingFiles = Object.keys(zip.files).filter((name) => {
  if (zip.files[name].dir) return false;
  const baseName = name.split('/').pop() || name;
  return audioFilePattern.test(baseName);
});

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

  • New test macOS resource-fork sidecars are not mistaken for history files builds 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).
  • All 6 Import robustness tests pass.
  • npm run lint:check 0 errors, npm run build clean.

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
@taurheim
taurheim merged commit a68ec9c into master Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant