Skip to content

Stale block_reason: publication requests never auto-clear when CI later passes #428

Closed

Description

@neuromechanist

Problem

When a user calls `nemar dataset publish request` while BIDS validation CI is still running or hasn't run yet, the backend correctly blocks the request with `block_reason='bids_validation_pending'` or `'bids_validation_in_progress'` (see `backend/src/routes/datasets.ts:1773-1794`). However, the block is one-shot: when the CI run later completes successfully, nothing automatically re-evaluates the request. The user has to remember to re-run `publish request` to retrigger the readiness check.

In practice users don't — the request sits in `blocked` indefinitely, looking to the user like the system rejected their dataset, when in reality the validator passed minutes after they hit submit.

Evidence

Triaged 2026-05-11. User bruaristimunha had 13 publication requests in `blocked` state since 2026-03-31:

dataset_id block_reason requested_at last CI run
nm000152 bids_validation_pending 2026-03-31 13:12:33 2026-04-29 success
nm000156 bids_validation_pending 2026-03-31 13:12:40 2026-04-02 success
nm000158 bids_validation_in_progress 2026-03-31 13:12:50 2026-04-11 success
nm000160 bids_validation_in_progress 2026-03-31 13:12:58 success
nm000161 bids_validation_pending 2026-03-31 13:13:06 success
nm000162 bids_validation_in_progress 2026-03-31 13:13:14 success
nm000163 bids_validation_in_progress 2026-03-31 13:13:21 success
nm000167 bids_validation_pending 2026-03-31 13:13:28 success
nm000168 bids_validation_pending 2026-03-31 13:13:35 success
nm000169 bids_validation_in_progress 2026-03-31 13:13:48 success
nm000176 bids_validation_pending 2026-03-31 13:14:26 2026-04-02 success
nm000186 bids_validation_pending 2026-03-31 13:14:33 success
nm000187 bids_validation_in_progress 2026-03-31 13:14:40 2026-04-02 success

All 13 had CI runs go green within hours of the original request, but the request status never moved. Cleared via direct SQL UPDATE to unblock the batch.

Root cause

`backend/src/routes/datasets.ts:1747-1827` only re-runs the readiness check on the explicit re-request code path. There is no listener for GitHub `workflow_run.completed` events that would re-evaluate any blocked publication request for that repo.

Proposed fix

Wire the GitHub webhook handler (`backend/src/routes/webhooks.ts` or wherever workflow_run is processed) to:

  1. On `workflow_run` with `name = 'BIDS Validation'` and `conclusion = 'success'`:

    • Find the corresponding `dataset_id` from `repository.name`.
    • For any `publication_requests` row with that `dataset_id` and `status = 'blocked'` and `block_reason` in `('bids_validation_pending', 'bids_validation_in_progress')`:
      • Transition to `status = 'requested'`, clear `block_reason`, bump `updated_at`.
      • Optionally fire the same admin-notification email that a fresh request sends.
  2. On `workflow_run` with `conclusion = 'failure'`:

    • For matching blocked rows, set `block_reason = 'bids_validation_failed'` so the message reflects current state.
  3. Add a daily cron sweep (defense in depth) that re-evaluates blocked rows older than 24h whose latest CI run is now green/failed, in case a webhook was missed.

Side note

The CLI's `nemar dataset publish status` should also surface the `block_reason` text and a hint to re-run `publish request`. Currently it only shows `Status: blocked`, leaving users in the dark about why.

Discovered by

Triaging bruaristimunha's 20 stuck publication requests (May 2026). Companion to #427.

Activity

  1. added
    P1
    bug
    backend
    on Jun 18, 2026
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

    P1backendbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions