Skip to content

Phase 2 (C): delete partial archive on build failure - #41

Merged
neuromechanist merged 1 commit into
mainfrom
fix/issue-739-archive-delete-on-failure
Jun 11, 2026
Merged

neuromechanist merged 1 commit into
mainfrom
fix/issue-739-archive-delete-on-failure

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Phase 2 (C) of epic nemarOrg/nemar-cli#736. Make a failed archive build stop being "sticky": the streaming script finalizes whatever it appended and completes the multipart upload before it exits non-zero on an incomplete build, so a failed run leaves a partial zip at the canonical key nemar/<id>/archives/v<X>.zip. Combined with the idempotency skip-if-exists guard, that partial turned every subsequent dispatch into a no-op until a human passed force=true (exactly what happened to nm000111).

This change deletes the canonical object on any non-zero exit of the streaming script, so a re-dispatch rebuilds cleanly.

Change (one step)

In "Stream archive to S3", wrap node /tmp/stream-archive.js, capture its exit code, and on non-zero exit aws s3 rm s3://nemar/<KEY> (tolerating a missing object) before propagating the failure.

Why delete-on-failure (vs temp-key-and-promote)

The normal publish path is already protected by the skip-if-exists guard, so it never overwrites a good archive. Only an explicit force=true rebuild can reach the delete with a prior good object present, and that is a deliberate recovery action. This avoids a server-side multipart copy for archives larger than 5 GB.

Closes nemarOrg/nemar-cli#739
Part of epic nemarOrg/nemar-cli#736

Test plan (real dispatches, no mocks)

On the disposable test dataset nm099999 (branch workflow via --ref):

  • Failure case: committed a dangling annex pointer (/annex/objects/SHA256E-s999--... to a non-existent S3 object), tagged it, and dispatched. The build skipped that blob (1 annexed + 8 regular + 1 skipped), exited 1, and the step logged removing any partial ... then delete: s3://nemar/nm099999/archives/v1.0.1.zip. After the run, archives/v1.0.1.zip is absent (anonymous HEAD -> 403) -- the partial did not linger.
  • Happy case: dispatched the clean v1.0.0; 0 skipped, succeeded, and archives/v1.0.0.zip remains present (200) -- delete-on-failure does not fire on success.

Note observed during testing (not a regression): creating a version tag fires the production version-doi -> generate-archive repository_dispatch path on main, which lacks this change, so it can re-create the partial if it races a manual force run for the same version. Once this merges to main, both paths delete-on-failure. Test artifacts (tags + fixture file) were cleaned up.

@neuromechanist

Copy link
Copy Markdown
Member Author

Sonnet /review-pr: no high-confidence issues across all six scrutiny points (exit-code capture, $KEY scope, || true, good-archive protection, failure-callback flow, MPU).

Deferred (not a false positive, out of scope for this workflow-only diff): if the runner is killed mid-stream before CompleteMultipartUpload, the streaming script may leave an incomplete multipart upload that aws s3 rm won't clean (it only removes completed objects). This is a pre-existing hazard of the streaming design, independent of delete-on-failure, and incomplete MPUs are normally reaped by an S3 lifecycle rule. Tracked as a follow-up on epic #736 rather than expanding this PR.

@neuromechanist
neuromechanist merged commit 4da9a8b into main Jun 11, 2026
1 of 3 checks passed
@neuromechanist
neuromechanist deleted the fix/issue-739-archive-delete-on-failure branch June 11, 2026 16:57
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.

Phase 2 (C): No sticky partial archive (temp-key promotion)

1 participant