Skip to content

Availability report: never create main on a repository nothing was pushed to - #1655

Closed
bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1643-availability-report-root-commit
Closed

bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1643-availability-report-root-commit

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

#1643: the availability-report sweep commits .nemar/availability-report.json to main through the Contents API. On nm000358, created but not yet pushed, that PUT created main as an unrelated root commit at 03:00 UTC. Every later nemar dataset upload failed at "Pushing metadata to GitHub" with [rejected] adjusted/main(unlocked) -> main (fetch first) (12 attempts), and the adjusted branch cannot be rebased onto it, so it needed a manual merge.

Change

  • New branchExists() in backend/src/services/github/contents.ts (a 404, or GitHub's 409 "Git Repository is empty", means no).
  • writeAvailabilityReport refuses with 409 when main does not exist instead of creating it.
  • The sweep only selects datasets that have a version (a version DOI or a dataset_versions row), the same rule as ARCHIVE_RETRY_SWEEP_QUERY: a never-versioned dataset has nothing to report, and a row the pass cannot complete must not hold one of its LIMIT slots.
  • Test seeds that model reportable datasets now carry a version.

Closes #1643

Testing

  • backend/test/github-branch-exists.test.ts (new, 4 tests): existing branch; 404 without retry; 409 "Git Repository is empty"; any other failure throws.

  • Candidacy SQL tests in availability-report-sweep-route.test.ts, and the updated archive-completeness / availability-report-at-migration seeds. 6 backend files that import the changed modules: 71 pass, 0 fail (on current dev).

  • bun run typecheck, biome check on the changed files.

  • The write path itself is not covered end to end, because it needs S3 for verifyDatasetVersionS3; branchExists and the candidacy are.

  • CI api-test and integration-dev fail on this PR because it comes from a fork: both call the dev API with the TEST_*_API_KEY secrets, which GitHub does not pass to fork pull requests, so the authenticated cases fail and the unauthenticated ones pass. lint, unit-pure and e2e-sandbox run normally.

The availability-report sweep commits .nemar/availability-report.json to
main through the Contents API. On a dataset that was created but whose
upload had not pushed yet, that PUT created main as an unrelated ROOT
commit. nm000358 (created 2026-10-06 14:55Z, report commit 4ba0a7b at
03:00Z): every later 'nemar dataset upload' attempt failed at 'Pushing
metadata to GitHub' with '[rejected] adjusted/main(unlocked) -> main (fetch
first)', and the adjusted branch cannot be auto-rebased, so the upload Job
failed after 12 attempts and needed a manual merge.

- writeAvailabilityReport checks that main exists (new branchExists: 404 or
  GitHub's 409 'Git Repository is empty' mean no) and refuses with 409
  instead of creating it.
- The sweep's candidates now require a version (a version DOI or a
  dataset_versions row), like ARCHIVE_RETRY_SWEEP_QUERY: a never-versioned
  dataset has nothing to report, and a row the pass cannot complete must not
  hold one of its LIMIT slots forever.
- Test seeds that model reportable datasets now carry a version.
@neuromechanist
neuromechanist changed the base branch from dev to feature/issue-1671-epic-bru-upload-fixes October 7, 2026 22:06
@neuromechanist

Copy link
Copy Markdown
Contributor

Thank you for this fix and for the careful write-up. It is merged into the integration branch for epic #1671 as PR #1672, with your commit kept (103f298 on that branch, authored by you). The review added commits on top, so this PR is closed in favor of that one.

What the review added: the branch check now runs before any S3 work and cannot sleep inside the sweep; a 404 on the ref is followed by a repository probe so an invisible repository is reported as such rather than as a missing main; the empty-repository 409 was confirmed against api.github.com and is matched on its body; a route-level test proves zero PUTs and zero S3 requests when main is absent; and the has-a-version predicate is now shared with the archive retry sweep so the two cannot drift.

The epic merges into dev as a unit once 0.10.15 has shipped. The full review record is on #1672.

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.

2 participants