Skip to content

S3 initremote fails on resume: bucket annex-uuid conflict after failed upload #336

Closed

Description

@bruAristimunha

Bug

nemar dataset upload fails when re-running after a previous failed upload in the same directory. The expected behavior is that re-running the command should resume/retry seamlessly — the user shouldn't need to delete anything or do manual recovery.

Steps to reproduce

  1. Run nemar dataset upload on a BIDS dataset
  2. Upload fails partway through (e.g., credential expiry after 2h, NFS error, network timeout)
  3. Re-run nemar dataset upload in the same directory (no manual cleanup)
  4. Configuring S3 remote... step fails:
✖ Failed to configure S3 remote: git-annex: there is no available git remote named "nemar-s3"
	origin
(No special remotes are currently known; perhaps use initremote instead?)

What's happening

On retry, nemar-cli correctly detects the existing dataset and resumes. But the S3 remote configuration fails because:

  1. initremote is called but the remote already exists in the git-annex branch from the first attempt → git-annex returns error "already a special remote"
  2. nemar-cli falls back to enableremote but the remote's UUID in the git-annex branch doesn't match what's expected → enableremote also fails

The user is stuck: initremote says "already exists", enableremote says "not found". The only current workaround is asking an admin to delete the NEMAR entry and starting over.

Additional issue: git-annex annex-ignore warning

When initremote runs, git-annex prints a warning to stderr about the GitHub origin remote:

Remote origin not usable by git-annex; setting annex-ignore

This causes initremote to exit with non-zero status even before attempting S3 initialization. The nemar-cli interprets this stderr output as a failure.

Environment

  • nemar-cli: 0.7.23 and 0.7.24-dev (commit 33a353d)
  • git-annex: 10.20260213
  • OS: Rocky Linux 8 (HPC login node)
  • Bun: 1.3.11

Expected behavior

Re-running nemar dataset upload after a failure should:

  1. Detect the existing dataset ✅ (works with 0.7.24-dev server-side dedup)
  2. Detect the existing S3 remote and reuse it ❌ (currently fails)
  3. Skip already-uploaded files and upload remaining ones
  4. Complete the upload

Suggested fixes

  1. Set remote.origin.annex-ignore = true before initremote to prevent the origin warning from causing a false failure
  2. Handle the "already a special remote" error by running enableremote with the correct credentials and S3 config parameters (currently enableremote is called without the bucket/region/prefix params)
  3. Or: when initremote fails with "bucket already exists, different UUID", delete the stale annex-uuid from S3 and retry

Affected datasets

This blocks re-upload of datasets that had partial upload failures:

  • nm000349 (Mainsah2025-B)
  • nm000150 (Liu2025)
  • nm000147 (RomaniBF2025ERP)

Activity

  1. added a commit that references this issue on Apr 1, 2026
    5c6143c
  2. neuromechanist commented on Apr 1, 2026

    @neuromechanist
    Contributor

    Hi @bruAristimunha, thanks for the detailed bug report! The root cause analysis was spot on.

    We've identified and fixed all three issues in PR #337:

    1. annex-ignore false failure: We now pre-set remote.origin.annex-ignore = true before calling initremote, so the GitHub origin warning no longer causes a false non-zero exit code.

    2. enableremote missing S3 params: The fallback enableremote call was only passing the remote name, not the bucket/region/prefix/credentials. It now passes the full S3 configuration, so the remote can properly reconnect on retry.

    3. No pre-check for existing remote: We now check git annex info --json for an existing remote before choosing between initremote (first time) vs enableremote (resume), avoiding the UUID conflict entirely.

    Once the PR is merged and released, please update your nemar-cli (bun install -g nemar-cli) and retry your uploads for nm000349, nm000150, and nm000147. The retry should now seamlessly detect the existing S3 remote and resume from where it left off.

    Let us know if you run into any issues!

  3. added a commit that references this issue on Apr 1, 2026
    daeccd3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions