Skip to content

fix(#450): push before CI deploy, bounded validation poll (#431) - #451

Merged
neuromechanist merged 2 commits into
devfrom
fix/issue-450-import-openneuro-push-order
May 13, 2026
Merged

neuromechanist merged 2 commits into
devfrom
fix/issue-450-import-openneuro-push-order

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Reorders importOpenNeuro so the initial git push to nemarDatasets happens before addCi(). The GitHub Contents API requires the target branch to exist; commitFilesAsTree(repo, "main", ...) 404s on a brand-new empty repo. CI deploy was failing on every fresh import, and the defensive git pull --rebase origin main that followed then exit-1'd with couldn't find remote ref main — leaving S3 data uploaded but git history never landing on the dataset repo.
  • Drops the pre-push pull entirely (a fresh repo has nothing to rebase against).
  • Replaces the unconditional skip_ci_check=true at approval (OpenNeuro import: replace skipCiCheck=true with bounded poll on workflow_runs #431) with a bounded 120s poll on getUserCiStatus; --trust-upstream opts in to the legacy fast-path for OpenNeuro imports (pre-validated upstream).
  • Onboarding workflow template (.github/dataset-workflows/onboard-openneuro.yml) updated to pass --trust-upstream.

Context

Run https://github.com/nemarDatasets/.github/actions/runs/25769577607 failed all 30 jobs with this exact failure mode. See #450 for full root-cause analysis. 28/30 hit the empty-remote pull bug; 2/30 (ds003800, ds007315) hit a separate annex-uuid idempotency issue that needs its own follow-up.

Test plan

  • bun run build clean
  • bunx tsc --noEmit clean
  • bunx biome check clean
  • Full suite passes the same count as on dev (4 pre-existing failures; new P1 issue filed)
  • --trust-upstream flag surfaces in nemar admin import-openneuro --help
  • Integration test = re-trigger nemarDatasets/.github onboard-openneuro.yml for the 28 broken datasets once the fix is on npm; importer is idempotent on already-uploaded S3 data so re-runs should be cheap.

After merge

  1. dev → main PR (release pipeline auto-bumps + tags + npm-publishes per CLAUDE.md).
  2. Update deployed nemarDatasets/.github/workflows/onboard-openneuro.yml to add --local --trust-upstream (currently only --local).
  3. Re-dispatch the workflow with the 28-dataset list.
  4. Address ds003800 / ds007315 stale annex-uuid in a separate follow-up.

Closes #450
Refs #431

Reorder importOpenNeuro so the initial git push to nemarDatasets runs
BEFORE addCi(): the GitHub Contents API requires the target branch to
exist, and on a freshly created empty repo commitFilesAsTree(repo,
"main", ...) 404s on the branch lookup. CI deployment was therefore
failing on every fresh import, and the subsequent defensive
git pull --rebase origin main then aborted the import with
"couldn't find remote ref main" — leaving S3 data uploaded but the
git history never landing on the dataset repo.

Also drop the pre-push pull entirely (the initial push to a fresh repo
has nothing to rebase against) and replace the unconditional
skip_ci_check=true at approval time (#431) with a bounded 120s poll on
getUserCiStatus; --trust-upstream opts in to the legacy fast-path for
OpenNeuro imports (pre-validated upstream). Onboarding workflow
template updated to pass --trust-upstream.

Closes #450
Refs #431
@github-actions

github-actions Bot commented May 13, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR451

Version: 0.8.12-PR451.e412eb7
Commit: e412eb7


🤖 Updated on each push.

Three review findings addressed:

1. waitForBidsValidationRun no longer swallows poll errors. Returns a
   discriminated union {found, timeout, error} so the caller can tell
   'never saw a run' from 'every poll attempt threw' and not silently
   approve a never-validated publication under --trust-upstream.

2. addCi failure is now fatal. --trust-upstream bypasses the validation
   lookup, not the deployment of validation/enrichment/archive workflows
   themselves — missing workflows mean no future safety net.

3. pushToGitHub warning (main pushed but git-annex branch failed) is now
   a hard fail for OpenNeuro imports. A published dataset whose
   git-annex branch is missing cannot be cloned.

Refactor: extract decideSkipCiCheck as a pure function. 7 real tests
cover the reachable matrix of (ciDeployed, poll outcome, trustUpstream).
Workflow YAML comment updated to match the new --trust-upstream scope.

Refs #450 #431
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review findings addressed (e412eb7)

Thanks for the catches. Fixed all three high-confidence issues and added the test-coverage agent's suggested pure-helper refactor.

  1. waitForBidsValidationRun no longer swallows errors. Returns a discriminated union {found, timeout, error} so the caller distinguishes "no run ever registered" from "every poll attempt threw" (auth/5xx/network). The error case is treated as a hard fail even under --trust-upstream — we never observed validation state, so silently approving would reintroduce the trust hole OpenNeuro import: replace skipCiCheck=true with bounded poll on workflow_runs #431 was meant to close.

  2. addCi() failure is now fatal. Previously, with --trust-upstream set, an addCi failure would set skipCiCheck=true and publish a dataset with no validation/enrichment/archive workflows. The flag bypasses validation lookup, not workflow deployment — the new code aborts on addCi failure regardless of --trust-upstream, with an actionable recovery hint pointing at nemar admin ci add <id>.

  3. pushResult.warning (git-annex branch push failure) is now a hard fail. A published dataset whose git-annex branch is missing cannot be cloned by downstream users. Previously this was only a spinner warning that scrolled past in CI logs.

Bonus refactor (per test-coverage analysis): extracted decideSkipCiCheck as a pure function and added test/import-openneuro.test.ts with 7 real assertions covering the reachable (ciDeployed, poll outcome, trustUpstream) matrix. No mocks, no injection seams, no network. The decision logic is now legible from a single function and verified to never silently approve under either failure mode.

Workflow YAML comment updated to reflect the tighter --trust-upstream scope (catches the comment-analyzer's drift between code and comment).

Reviews summary:

  • code-reviewer: 3 issues — addressed
  • silent-failure-hunter: 3 critical/high + 2 medium (audit-trail, exit-state hints) — high/critical addressed; the two medium suggestions deferred to follow-ups
  • comment-analyzer: 1 critical (workflow YAML comment scope) — addressed
  • pr-test-analyzer: refactor + 5 assertions — done, 7 in practice

This branch was previously deployed

1 inactive deployment
npm — e412eb73 Deployed May 13, 2026 by neuromechanist via publish #780
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant