Skip to content

Improve upload workflow: auto-accept invitations, commit authorship, resume support #41

Closed
6 of 6 issues completed

Description

@neuromechanist

Summary

After extensive debugging of the S3 upload flow and GitHub push workflow, we identified several improvements needed for a smooth user experience.

Root Cause Analysis

Issue 1: IAM Eventual Consistency (FIXED in dev)

  • Problem: When creating a dataset, IAM policy is updated but S3 uploads fail with 403 because policy hasn't propagated
  • Solution: Added retry logic (10s, 15s, 20s, 25s delays) for 403 AccessDenied errors + 10s initial wait
  • Commit: 08d3aa7

Issue 2: Commit Authorship

  • Problem: Commits are authored as whoever's git config is set locally, not the NEMAR user
  • Example: cool-vibers uploads but commit shows "Seyed Yahya Shirazi"
  • Solution: Use git commit --author="username <email>" with NEMAR registration email

Issue 3: GitHub Invitation Acceptance

  • Problem: User is added as collaborator but must manually accept invitation in browser before pushing
  • Solution: Auto-accept via CLI using:
    gh api /user/repository_invitations  # List pending
    gh api --method PATCH /user/repository_invitations/{id}  # Accept
  • Requirement: User must have gh CLI authenticated as their GitHub account

Issue 4: Branch Protection Timing

  • Current: Branch protection applied immediately after dataset creation
  • Problem: For private repos, owner should be able to push directly to main
  • Proposed:
    • Private repos: No branch protection on main
    • When making public OR creating DOI: Apply branch protection (require PR)
    • Rationale: DOI = permanent, needs protection; private = owner's sandbox

Issue 5: Resume Failed Uploads (relates to #40)

  • Problem: If DataLad/git-annex/S3 upload fails mid-way, user cannot resume
  • Current: Must start over with new dataset ID
  • Proposed:
    • nemar dataset upload should detect existing dataset
    • Check what's missing on GitHub and S3
    • Resume/sync rather than fail
    • git-annex handles this natively with git annex copy

Proposed Upload Flow

1. User runs: nemar dataset upload ./my-data
2. CLI validates BIDS
3. CLI calls API to create dataset (or resume existing)
4. API creates GitHub repo + invites user as collaborator
5. CLI auto-accepts invitation via gh API
6. [10s wait for IAM propagation]
7. CLI uploads to S3 with retry logic
8. CLI commits with --author="username <email>"
9. CLI pushes to GitHub (user's identity)
10. CLI finalizes (no branch protection for private)

Tasks

  • Use --author flag for commits with NEMAR user email
  • Add gh api invitation acceptance after dataset creation
  • Verify gh CLI is authenticated as correct user before upload
  • Change branch protection to only apply when:
    • Dataset is made public, OR
    • DOI is created
  • Add resume capability for failed uploads
  • Update documentation with new flow

Related Issues

Test Machines

  • yahyas-mcm (ssh mcm): Admin account (yahya)
  • yahyas-mba (ssh mba): Test user (cool-vibers)
  • Note: nemar CLI requires zsh -i -c when running via SSH

Sub-issues

Sub-issues

6 of 6 Issues completed
Loading 6 sub-issues

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