Repository navigation
Description
Problem
@PierreGtch uploaded dataset nm000109 (72 EEG files, 174MB) from SDSC Expanse (HPC). The S3 upload succeeded, but all 72 URL registrations failed silently, making downloads completely broken.
What happened
- First upload attempt:
safe.directoryerror (HPC ownership issue, expected) - Second attempt (after
git config --add safe.directory):Could not switch to unlocked mode; data files will be symlinks- S3 upload succeeded (72 files via AWS CLI)
- "Some URLs could not be registered (72 failed)" -- all files failed
- Upload reported success anyway
- Download attempt:
git annex getfails with "No other repository is known to contain the file"
Root cause
The upload workflow has a fragile two-step process:
- Upload bytes to S3 via AWS CLI or presigned URLs (bypasses git-annex)
- Retroactively register S3 URLs via
git annex add->lookupkey->registerurl
Step 2 fails when git annex add fails (errors silently swallowed at git-annex.ts:1305-1307). On HPC environments with filesystem quirks (symlink issues, ownership), this step is unreliable.
Design inconsistency
- Initial upload: presigned URLs + registerurl (fragile, git-annex not in the loop)
- Subsequent updates (
dataset update,dataset push): expectsgit annex copy --to nemar-s3(S3 special remote that was never configured during initial upload)
Immediate fix applied
Manually registered S3 URLs for nm000109 by cloning, extracting annex keys from pointer files, and running git annex registerurl for all 72 files. Download now works.
Solution: Use S3 Special Remote from Initial Upload
Replace the presigned URL + registerurl approach with git-annex's native S3 special remote for both upload and download.
How it works
git annex initremote nemar-s3 type=S3 encryption=none bucket=nemar fileprefix={id}/objects/ datacenter=us-east-2 signature=v4 publicurl=https://nemar.s3.us-east-2.amazonaws.com- Upload:
git annex copy --to nemar-s3with STS temp credentials (already have STS endpoint) - Download:
git annex getuses publicurl (no credentials needed, S3 bucket is public-read) - git-annex handles key-to-URL mapping internally -- no separate registerurl step needed
Workflow scenarios to validate
Scenario 1: Initial dataset creation
git annex init+git annex initremote nemar-s3 ...with STS credsgit annex add .(track data files)git annex copy --to nemar-s3 -J4(upload with STS creds)git push origin main git-annex
Scenario 2: Download
git clone+git annex initgit annex enableremote nemar-s3(reads config from git-annex branch, uses publicurl for reads)git annex get .(fetches from S3 public URL)
Scenario 3: Update private dataset (direct push)
- Clone or use existing local copy
- Make changes,
git annex add . - Get STS creds,
git annex copy --to nemar-s3 . git push origin main git-annex
Scenario 4: Update public dataset (PR required)
- Clone, create branch
- Make changes,
git annex add . - Get STS creds,
git annex copy --to nemar-s3 .(data goes to final location) - Create PR, push branch + git-annex
- On merge: data already in place, CI tags release
Implementation tasks
- Replace upload path: After
git annex init, configure S3 special remote with STS creds and publicurl. Usegit annex copy --to nemar-s3instead of AWS CLI sync + registerurl. - Fix download path: After clone +
git annex init,enableremote nemar-s3so git-annex knows about the S3 remote.git annex getthen fetches via publicurl. - Remove dead code: Delete
registerUrlWithGitAnnex,registerUrlsWithGitAnnex,configureWebRemotefunctions and presigned URL upload path (or keep as emergency fallback). - Validate STS creds with git-annex: Confirm
AWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEY+AWS_SESSION_TOKENenv vars work withgit annex initremoteandgit annex copy. - Validate publicurl download: Confirm
git annex enableremote nemar-s3works without credentials when publicurl is set (read-only via public S3). - Test on HPC-like environment: Verify the S3 remote approach works on systems where symlinks/ownership cause issues (the filesystem quirks that broke registerurl).
- Ensure
dataset updateanddataset pushwork: These commands already expect an S3 remote; verify they work end-to-end after the change.
Fallback consideration
Keep presigned URL upload as emergency fallback (some locked-down environments block STS), but make S3 special remote the primary path.
Files to modify
src/lib/git-annex.ts- Wire upconfigureS3Remote()(already written), remove/deprecate registerurl functionssrc/commands/dataset.ts- Replace upload Step 9+10 with S3 remote init +git annex copysrc/lib/git-annex.ts- UpdatecloneDatasetorgetDatasetDatatoenableremotebeforegit annex get
Activity
Replace registerurl with S3 special remote
neuromechanist commentedon Feb 24, 2026
Final Design Decisions (from E2E testing)
1.
protocol=httpsrequired for S3 special remotegit-annex defaults to HTTP for S3 operations. With STS temporary credentials, HTTP requests fail with 403 because AWS STS requires HTTPS. Added
protocol=httpstoinitremoteargs.2. Clear cached STS credentials after upload
git-annex caches AWS credentials in
.git/annex/creds/duringinitremote. When using STS temporary credentials, these expire and cause 403 errors on subsequent downloads instead of falling back topublicurl. Solution:clearAnnexCredentials()removes cached creds after each successful upload sogit annex getuses the publicurl for downloads.3. Unconditional
s3:ListBucketin STS policygit-annex runs
HeadBucketduringinitremoteto verify the bucket exists. This requiress3:ListBucketwithout any prefix condition. The original policy had a prefix condition (s3:prefix: [{datasetId}/objects/*]) which blocked HeadBucket. Removed the condition.4. Upload flow
5. Download flow
Old datasets without S3 remote:
enableS3Remote()returns gracefully, download falls back to web remote URLs.Verified via E2E testing
initremotewithprotocol=httpssucceedscopy --touploads file to S3 with correct key-based layoutgit annex getdownloads via publicurl without credentialsfix(sandbox): migrate to S3 special remote, add --verbose
fix(sandbox): migrate to S3 special remote, add --verbose (#378)