Skip to content

nemar dataset push fails the S3-upload step in two distinct paths #401

Closed

Description

@bruAristimunha

The CLI's S3-upload step inside nemar dataset push (and --pr / nemar dataset update) consistently fails to upload annex content for collaborators of public datasets. Two independent bugs combine. Repro'd against on003825, nm000133, nm000134 on [email protected] and 0.8.8, git-annex 10.20260213.


Bug A — getAnnexS3Remotes doesn't filter remotes with annex-ignore=true

Affected: on003825 and almost certainly every other dataset under nemarDatasets/on* imported from OpenNeuro (the s3-PUBLIC / s3-PRIVATE remotes are inherited from the upstream OpenNeuro mirror).

Code locations:

  • src/lib/git-annex.ts (around lines 1798-1860) — getAnnexS3Remotes
  • src/commands/dataset.ts (around line 4221) — push-data step

Repro:

nemar dataset clone on003825
cd on003825
git remote -v
# nemar-s3
# origin     https://github.com/nemarDatasets/on003825.git
# s3-PUBLIC                          <-- inherited from upstream OpenNeuro mirror
# s3-PRIVATE                         <-- ditto

# Stage annexable changes, then:
nemar dataset push --pr -t … -b …

Symptom: every `copy stimuli/.jpg` fails with
```
Remote is configured to use versioning, but no S3 version ID is recorded for this key
(cannot check content) failed
```
The CLI prints a final `Git changes were pushed successfully.` so it looks half-successful, but no annex content lands on S3.

Root cause: `getAnnexS3Remotes` enumerates S3 remotes via `git config --get-regexp '^remote\..*\.annex-s3'` and picks `s3Remotes[0]` as the upload destination, without filtering remotes whose `remote..annex-ignore` is `true`. For OpenNeuro mirrors that list returns `[s3-PUBLIC, nemar-s3]` in that order, so the CLI uploads to the inherited `s3-PUBLIC` remote which is configured with `versioning=yes exporttree=yes`. git-annex's "no S3 version ID recorded for this key" branch then fires for every new key. `git annex info nemar-s3` shows `annex-ignore=false`; the picker should consult `remote..annex-ignore`.

Workaround:

git remote remove s3-PUBLIC
git remote remove s3-PRIVATE
nemar dataset push     # now uploads cleanly

Suggested fix: in `getAnnexS3Remotes`, skip any remote where `git config remote..annex-ignore=true`. As a follow-up, when more than one valid candidate remains, prefer the one whose UUID matches the configured `nemar-s3` (or whose description equals `[nemar-s3]`) before falling back to first-match.


Bug B — `push` doesn't recover when the API denies upload credentials

Affected: `nm000133`, `nm000134` and likely every dataset where the user has GitHub `push:true` but hasn't yet `nemar dataset request-access`-ed (i.e. is a GitHub collaborator but not a NEMAR collaborator).

Repro:

gh api 'repos/nemarDatasets/nm000133' -q .permissions
# {\"admin\":false,\"maintain\":false,\"pull\":true,\"push\":true,\"triage\":true}

cd nm000133
git checkout -b stimuli-add main
# … stage / commit some annex content …
nemar --verbose dataset push --pr -t … -b …

Symptom:

- Pushing to GitHub...
✔ Pushed to GitHub
- Requesting upload credentials...
⚠ Could not get upload credentials: Only dataset owner or collaborators can request upload credentials. Trying environment credentials.
- Copying data to S3 (nemar-s3)...
✖ S3 push failed
  copy stimuli/train2017/000000000584.jpg (to nemar-s3...)
    Set both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to use S3
    No S3 credentials configured
  failed
  …× N keys…
  Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set,
  or log in with 'nemar auth login' for automatic credentials.
  Git changes were pushed successfully.

Two things that go wrong here:

  1. The user IS auth'd. `nemar whoami` returns the right account; the API key is in `~/.config/nemar/config.json`. The fall-through error message "or log in with `nemar auth login` for automatic credentials" is misleading — login isn't the issue, the NEMAR-collaborator status is.
  2. The PR is never created even though `--pr` was passed and git push succeeded. The CLI aborts on S3 failure and never reaches PR creation, so the user is left with a remote branch and no PR.

Workaround (which the CLI should arguably do automatically):

nemar dataset request-access nm000133   # auto-approved if user has GH push perm
nemar dataset push                       # now succeeds end-to-end

Suggested fixes:

  1. On the "Only dataset owner or collaborators can request upload credentials" response, instead of falling through to env-var creds, either retry once after auto-calling `request-access`, or surface a directly actionable message like "Run `nemar dataset request-access ` first". The current message points at the wrong fix.
  2. Make the `--pr` flow idempotent / order-independent: if S3 fails but git push succeeded, still create the PR (or detect an existing branch and reuse it), so the user can later retry just the S3 phase via `nemar dataset push --no-pr`.
  3. The "Trying environment credentials." path should print what env-var values it actually found (or explicitly "AWS_ACCESS_KEY_ID not set in env") so the misleading suggestion to set env vars is concretely diagnosable.

Bonus DX suggestion

`nemar dataset collaborators ` returns `Only dataset owner or admin can view collaborators` for non-owners — fair. But there should be a `nemar dataset whoami ` (or `nemar whoami --in `) that reports for the current user, on this dataset: GitHub permission level, NEMAR-collaborator status, S3 upload allowed (yes/no). That single command would have made both of these bugs visible in 5 seconds.


Evidence

End-to-end runs (with PRs that show the half-completed state):

Happy to provide `--verbose` logs or push attempts on a specific commit if useful.

Activity

  1. bruAristimunha commented on May 1, 2026

    @bruAristimunha
    ContributorAuthor

    Bug C — nemar dataset push does not push the git-annex branch to origin

    While verifying the on003825 / nm000133 / nm000134 PRs by doing a fresh nemar dataset download, every annex get for the new annex content failed:

    Getting 1 path(s) (1 files, 150.7 KB)...
                     get: 1 failed
    

    git annex whereis on the failing file showed it as only present on the local clone where the push originated:

    whereis stimuli/train2017/000000000584.jpg (1 copy)
      90ee3e52-…  baristim@margaret02:/data/tau/iceberg_1/titanic_1/datasets/bids/nm000133
    

    Yet the source clone, on the same path, sees nemar-s3 as having all the keys:

    # source clone (where the push ran)
    git annex info nemar-s3 | grep keys      # remote annex keys: 1001
    git log -1 --format=%h git-annex          # acdc37a   <-- local
    git log -1 --format=%h origin/git-annex   # 94e35dc   <-- remote (older!)
    
    # fresh clone
    git annex info nemar-s3 | grep keys      # remote annex keys: 41   <-- only the EEG that was already there
    

    So the binary content did make it onto S3 (it's there — the source clone can get from it just fine), but the git-annex branch commits that record "key X is now on nemar-s3" never got pushed to origin. Anyone cloning fresh therefore can't find the new annex objects on any remote.

    The CLI's help text claims it pushes both: "Push git commits to GitHub (main + git-annex branches) and optionally copy annexed data to the S3 remote." In practice it only pushed stimuli-add, not the git-annex branch.

    Fix from the user side:

    # After `nemar dataset push` reports success, also:
    git push origin git-annex

    Once that landed, git fetch origin git-annex from a fresh clone followed by nemar dataset get works:

    remote annex keys: 1001
    [100%] 959 files | 165.3 MB | 7.3 MB/s
    

    Suggested fix in the CLI: at the end of the S3 copy step, do an explicit git push origin git-annex (or git push origin --all scoped to that branch). The current state where the binary content is uploaded but the location records are not is a silent corruption that only surfaces when someone else tries to download — exactly what would happen for an end user, not the maintainer who pushed.

    This affected all three PRs in the original report (on003825, nm000133, nm000134). Reproducible with the latest 0.8.8.

  2. bruAristimunha commented on May 9, 2026

    @bruAristimunha
    ContributorAuthor

    hey @arnodelorme and @neuromechanist,

    any update about this?

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