Skip to content

Run readiness checks on publication request and block if CI fails #270

Closed

Description

@neuromechanist

Problem

Currently, when a user requests publication (POST /datasets/:id/publish/request), the endpoint just inserts a DB row and emails admins. No validation happens. Admins then discover issues (failing BIDS validation, missing enrichment) only when they try to approve.

This wastes time and leaves datasets stuck in a "requested" state with no feedback to the user.

Proposed Behavior

When a user requests publication, the backend should:

1. Deploy CI if missing

  • Check if BIDS validation workflow exists on the dataset repo
  • If missing, deploy it (equivalent to nemar admin ci add)
  • Trigger a validation run

2. Check BIDS validation status

  • Query the latest CI run for the BIDS validation workflow
  • If failing: set request status to blocked with reason bids_validation_failed
  • If no runs yet: set status to pending_ci and check again later (or instruct user to push)

3. Trigger LLM metadata enrichment

  • Check if .nemar/metadata.json exists and its pipeline_stage
  • If enrichment hasn't run, trigger the LLM enrichment workflow

4. Block or proceed

  • If BIDS validation passes and enrichment is complete (or in progress): create the request normally, email admins
  • If BIDS validation fails: create the request with status: 'blocked', do NOT email admins yet. Return a clear message to the user:
    {
      "status": "blocked",
      "reason": "bids_validation_failed",
      "message": "BIDS validation is failing on your dataset. Please check the repository CI and fix validation errors before requesting publication.",
      "ci_url": "https://github.com/nemarDatasets/<id>/actions"
    }

5. Status endpoint reflects block reason

GET /datasets/:id/publish/status should show:

{
  "status": "blocked",
  "block_reason": "bids_validation_failed",
  "message": "BIDS validation is failing. Please fix validation errors and re-request.",
  "ci_url": "https://github.com/nemarDatasets/<id>/actions"
}

6. Unblocking

  • When user fixes issues and re-requests (POST /datasets/:id/publish/request), re-run the checks
  • If CI now passes, transition from blocked to requested and email admins
  • Alternatively: a webhook on CI success could auto-unblock

Schema Changes

Add to publication_requests table:

  • block_reason TEXT - why the request is blocked (e.g., bids_validation_failed, enrichment_incomplete)

Add new status value: blocked (alongside existing requested, approving, published, denied)

Email Policy

  • Do NOT email admins when request is blocked (user needs to fix first)
  • Do NOT spam users with repeated CI failure emails
  • Email user ONCE when request is blocked with clear instructions
  • Email admins only when request transitions to requested (all checks pass)

CLI Changes

nemar dataset publish request should display the block reason:

Publication request blocked: BIDS validation is failing.
Please check CI results: https://github.com/nemarDatasets/nm000112/actions
Fix validation errors and run `nemar dataset publish request` again.

nemar dataset publish status should show block status:

Status: Blocked
Reason: BIDS validation failing
CI: https://github.com/nemarDatasets/nm000112/actions

Implementation Notes

  • Reuse existing checkCIStatus() logic from the ci_check step in the approve pipeline
  • The annex pointer issue (BIDS validation CI fails on git-annex pointer files #267) should also be fixed so CI results are meaningful
  • Front-loading these checks means admin approve pipeline can skip steps 1-2 if already verified
  • Consider: should we also check if dataset has at least one version/tag? Or any other basic readiness?

Related Issues

Activity

  1. added 3 commits that reference this issue on Mar 9, 2026
    d64a8a0
    541e7cb
    bdcd5c6
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