Skip to content

sandbox: orphaned GitHub repo + S3 prefix on failed run #379

Closed

Description

@neuromechanist

Symptom

When nemar sandbox fails after createDataset returns (any of the eight downstream error paths in src/commands/sandbox.ts), the GitHub repo (under nemarDatasets/xx*) and the S3 prefix (s3://nemar/xx*/objects/) are left orphaned. cleanupSandboxDataset(datasetPath) only removes the local temp directory.

Impact

  • Each failed retry provisions a fresh xx-prefixed dataset rather than reusing the orphan.
  • WSL/HPC users hitting gitAnnexAdd or copyToAnnexRemote failures repeatedly accumulate orphans.
  • The 14-day sandbox sweep (per nemar-cli/CLAUDE.md) eventually catches them, but in the meantime the user is never told the server-side resource exists.
  • Re-running offers no resume path, even though the GitHub repo + S3 prefix are still valid.

Affected paths

All post-createDataset failure paths in src/commands/sandbox.ts:

  • acceptGitHubInvitation invalid URL
  • initDataset / configureLargefiles / configureGitHubRemote
  • requestUploadCredentials
  • configureS3Remote
  • gitAnnexAdd
  • copyToAnnexRemote
  • saveDataset / pushToGitHub
  • finalizeDataset

Proposed fix

Wire a single failSandbox(datasetId, datasetPath) helper that:

  1. Calls DELETE /admin/datasets/:id (or a sandbox-scoped equivalent that does not require admin) to remove the GitHub repo + S3 prefix + D1 row.
  2. Calls cleanupSandboxDataset(datasetPath) for the local temp dir.
  3. Falls back to a user-visible warning if the backend teardown fails (so they know to clean up manually).

Route every post-createDataset error path through failSandbox instead of cleanupSandboxDataset alone.

Notes

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions