Repository navigation
Fix nemar dataset push --pr S3 upload failures (#401) - #404
Merged
Merged
Conversation
Bug A from #401: getAnnexS3Remotes returned every annex-S3 remote in alphabetical order, so OpenNeuro-imported datasets like on003825 that inherit s3-PUBLIC alongside nemar-s3 had push uploads land in the wrong bucket. - getAnnexS3Remotes now skips remotes with annex-ignore=true. - New selectAnnexS3Remote prefers the canonical nemar-s3 name, then the [nemar-s3] annex description, then first match. - import-openneuro now marks inherited s3-PUBLIC/s3-PRIVATE as annex-ignore=true after building the URL map, so future imports filter cleanly even without the name preference. Tests cover the filter, the preference, and the empty-list fallback.
Bugs B and C from #401: Bug B: when requestUploadCredentials returned 403 'Only dataset owner or collaborators can request upload credentials', the CLI silently fell through to environment AWS credentials and then aborted with a misleading 'log in with nemar auth login' message. With --pr passed, git push had already succeeded but the PR was never created, leaving the user with a remote branch and no PR. - Detect the 403 collaborator error and auto-call requestDatasetAccess once, then retry credentials. Public datasets auto-approve so this is non-interactive in the common case. - On retry failure, surface an actionable command ('nemar dataset request-access <id>') instead of the AWS env-vars hint. - Print AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY status when falling back so the env-vars hint is concretely diagnosable. - Track s3PushFailed and skip process.exit so PR creation still runs — users can retry the data step with --no-pr later. Bug C: pushToGitHub at the start of the push command pushes the git-annex branch, but git annex copy --to nemar-s3 then writes new location records to the local git-annex branch that never reach origin. Fresh clones would then see the data on S3 but no record that it's there, leaving 'whereis' empty. - After a successful copyToAnnexRemote, push the git-annex branch again so location records ship with the PR.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR404Version: 🤖 Updated on each push. |
neuromechanist
force-pushed
the
feature/issue-401-fix-push-s3
branch
from
May 10, 2026 21:07
e2d9f2d to
20e96ee
Compare
Replace runCommand call (lib-internal helper not exported) with the spawn pattern already used elsewhere in this file. Resolves CI tsc 'Cannot find name runCommand' on src/commands/dataset.ts:4323.
neuromechanist
force-pushed
the
feature/issue-401-fix-push-s3
branch
from
May 10, 2026 21:10
20e96ee to
667357e
Compare
Code review (4 agents) on PR #404 surfaced: dataset.ts push command: - s3PushFailed was set but never read — restore process.exit(1) when data upload fails (caller scripts/CI relied on the exit code). - clearAnnexCredentials moved into a finally so STS creds are wiped from .git/annex/creds/ on failure too; an interrupted upload would otherwise leave expired tokens that 403 subsequent operations. - Distinguish transient backend errors from real permission denials when the auto request-access retry fails: only 4xx routes the user to 'nemar dataset request-access', 5xx tells them the credentials service is unavailable. - git-annex push failure escalated from chalk.dim to chalk.yellow and now also sets s3PushFailed so the partial-state exit code is honest about clones not being able to locate the new files. - Drop the 'Bug C:' comment prefix and a restating comment that added no information. git-annex.ts: - Extract markInheritedOpenNeuroRemotesIgnored helper so the same marking that import-openneuro does can be exercised in tests. - Surface JSON parse errors in selectAnnexS3Remote via console.warn instead of silently falling through; malformed git-annex info is the kind of state worth telling the user about. import-openneuro.ts: - Move the annex-ignore marking outside the !options.skipData guard so --skip-data imports still get clean filtering on later pushes. - Surface failed git config calls instead of silently leaving the remote half-ignored. Tests: - selectAnnexS3Remote description tiebreaker (alt-name remote described as [nemar-s3] beats alphabetically-first s3-PUBLIC) - markInheritedOpenNeuroRemotesIgnored marks both inherited remotes and reports which were marked - markInheritedOpenNeuroRemotesIgnored skips remotes that aren't configured (no-op on fresh repo) - Regression guard: 'git annex copy' to a directory remote really does advance the local git-annex branch — the invariant the Bug C re-push depends on
5 of 7 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #401. Tracking epic for the staging workflow design opened as #403.
Summary
Three independent bugs in `nemar dataset push` that combined to silently corrupt push state for OpenNeuro-imported datasets and any user without NEMAR-collaborator status. on003825 hit Bug A in PR #1 (merged to main); the dataset's main branch has been hand-recovered as part of this work — see below.
Bug A: wrong S3 remote for OpenNeuro-imported datasets
`getAnnexS3Remotes` enumerated every annex-S3 remote and `dataset.ts:4221` blindly picked `s3Remotes[0]`. For datasets imported from OpenNeuro (`on*`), the inherited `s3-PUBLIC` ranks first and gets selected instead of `nemar-s3`. Uploads then fail with "no S3 version ID is recorded for this key" against OpenNeuro's versioned bucket, while the CLI prints "Git changes were pushed successfully".
Fixes:
Bug B: 403 collaborator error silently lost the PR
When a user has GitHub `push` on a dataset repo but is not a NEMAR collaborator, `requestUploadCredentials` returned 403 "Only dataset owner or collaborators...". The CLI fell through to env credentials, then S3 failed and `process.exit(1)` killed the run before `--pr` got to create the PR. The fallback message also misleadingly suggested `nemar auth login`.
Fixes:
Bug C: git-annex branch lost the new location records
`pushToGitHub` runs at the start of the push command and pushes `git-annex` once. `git annex copy --to nemar-s3` then writes new location records to the local `git-annex` branch that never reach origin. Fresh clones see the data on S3 but no record it's there, so `git annex whereis` returns "0 copies".
Fix: after a successful `copyToAnnexRemote`, re-push `git-annex` so location records ship with the PR. Failure is a warning, not fatal.
on003825 recovery
Verified empirically on the live dataset: all 26,107 stimuli MD5E keys were already present in `s3://nemar/on003825/objects/` from the merged PR upload; only the location records were missing. Recovery was metadata-only:
```bash
git annex find --include='stimuli/*' --format='${key} 1\n' | git annex setpresentkey --batch
git push origin git-annex
```
Fresh clone of on003825 now reports `whereis` with `[nemar-s3]` as a valid copy and `nemar dataset get` works end-to-end.
Out of scope
The deeper architectural gap, where `.context/pr_architecture.md` describes a staging->merge->final flow but the wiring uploads directly to final, is tracked in #403 and will be designed and implemented separately. The bugs in this PR exist in either model, so this fix is independent of that decision.
Test plan