Skip to content

fix(snapshot): stop the CI Test flake — never snapshot from a failed git add, verify revert deletions against a full tree listing#13

Closed
Aayam Bansal (aayambansal) wants to merge 2 commits into
mainfrom
ci-snapshot-hardening
Closed

fix(snapshot): stop the CI Test flake — never snapshot from a failed git add, verify revert deletions against a full tree listing#13
Aayam Bansal (aayambansal) wants to merge 2 commits into
mainfrom
ci-snapshot-hardening

Conversation

@aayambansal

Copy link
Copy Markdown
Member

The required Test check has been failing on most Linux runs with unicode filenames modification and restore — ENOENT after revert, every sandbox file deleted. Two defects compound:

  1. track() swallowed git add failures via .nothrow(). write-tree then snapshots a stale/empty index, and revert() against that tree deletes every file as 'not in snapshot'. Now staged via stageAll(), which retries once and reports failure — track() returns no snapshot instead of a wrong one. This was also a destructive-in-production bug: a transient git error could delete user files on revert.

  2. revert() verified deletions with a per-file ls-tree <hash> -- <pathspec> whose behavior differs across platforms for unusual filenames. Replaced with one ls-tree -r --name-only listing per snapshot (quotepath=false, the same mechanism patch() uses), checked in code — deterministic on every platform, fewer git calls, and fail-safe: if the listing errors, files are kept rather than deleted.

Same change already passed the full Test suite on the #9 branch. Landing it on main separately so every open PR inherits a green base.

The 'unicode filenames modification and restore' test failed CI on push
43b5e18 with ENOENT after revert: every file in the sandbox was deleted.
That happens when the 'git add' inside track() fails transiently and
.nothrow() swallows it — write-tree then snapshots an empty index, and
revert() against that tree treats every file as 'not in snapshot' and
unlinks it.

- stage via a shared stageAll() that retries once on failure and reports
  it; track() returns no snapshot instead of a wrong one when staging or
  write-tree fails
- revert() no longer deletes a file when the ls-tree verification itself
  errors; deletion now requires a successful ls-tree that confirms the
  file was absent from the snapshot
The per-file 'ls-tree <hash> -- <pathspec>' check behaved differently
across platforms for unusual filenames, so revert either kept files it
should delete or vice versa depending on OS. List the snapshot tree once
per patch with core.quotepath=false (the same mechanism patch() uses)
and check membership in code: deterministic on every platform, one git
call per snapshot instead of per file, and still fails safe — if the
listing errors, files are kept rather than deleted on an unverified
miss.
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openscience Ready Ready Preview, Comment Jul 4, 2026 6:28pm

Request Review

@aayambansal

Copy link
Copy Markdown
Member Author

Superseded — the same snapshot hardening landed on main via #9's squash merge. A follow-up PR replaces the checkout-based restore entirely.

@aayambansal Aayam Bansal (aayambansal) deleted the ci-snapshot-hardening branch July 4, 2026 18:37
Aayam Bansal (aayambansal) added a commit that referenced this pull request Jul 7, 2026
…omic temp, env prefixes (#123)

Four defensive fixes in the managed-account module:

- atlasFetch now COMBINES a caller-supplied signal with the timeout via
  AbortSignal.any instead of replacing it, so passing a signal never drops
  the 60s hang guard. (#46)
- refreshIfStale coerces a numeric-string sync version ({"v":"5"}) instead
  of collapsing it to null — otherwise cached_v never updates and the CLI
  keeps deferring the background sync forever. (#47)
- atomicWrite's temp path is unique per call (pid + uuid), so two concurrent
  syncs in the same process can't write the same temp file, interleave, and
  publish a torn synced-env.json. (#13)
- filterEnvForSubprocess matches SAFE_ENV_PREFIXES exactly for plain names and
  only prefixes entries ending in '_' (LC_, XDG_), so HOME no longer matches
  HOMEBREW_GITHUB_API_TOKEN etc. (#49)
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