can1357/oh-my-pi · warning · HTTPException

unknown delivery {target}

Error message

unknown delivery {target}

What it means

The retry endpoint looked up the supplied delivery_id in the database and found nothing, returning HTTP 404 'unknown delivery <target>'. Unlike error 4025 (issue-based lookup found no stored event), this fires on the direct path: `db.get_event(target)` returned None for the delivery id you passed. The id is well-formed but no event with it exists in this server's store.

Source

Thrown at python/robomp/src/server.py:659

        if isinstance(delivery_id, str) and delivery_id:
            target = delivery_id
        elif isinstance(issue_ref, str) and issue_ref:
            try:
                repo_full, number = parse_issue_ref(issue_ref)
            except InvalidIssueRef as exc:
                raise HTTPException(400, str(exc)) from exc
            if not cfg.allows(repo_full):
                raise HTTPException(403, f"{repo_full} not in ROBOMP_REPO_ALLOWLIST")
            row = db.latest_event_for_issue(make_issue_key(repo_full, number))
            if row is None:
                raise HTTPException(404, f"no retryable stored event for {repo_full}#{number}")
            target = row.delivery_id
        else:
            raise HTTPException(400, "retry requires 'delivery_id' or 'issue'")

        event = db.get_event(target)
        if event is None:
            raise HTTPException(404, f"unknown delivery {target}")
        if not db.requeue_event(target, from_states=INACTIVE_EVENT_STATES):
            raise HTTPException(409, f"delivery {target} is {event.state}; only inactive events can be retried")
        pool.wake()
        log.info("manual retry", extra={"delivery": target})
        return JSONResponse(
            {"delivery": target, "state": "queued", "mode": "retry"},
            status_code=202,
        )

    @app.post("/api/cancel")
    async def api_cancel(
        request: Request,
        payload: dict[str, Any] = Body(...),
        x_robomp_token: str | None = Header(None, alias="X-Robomp-Replay-Token"),
    ) -> JSONResponse:
        """Stop a running event. The omp subprocess is killed; the row lands in
        `failed` with `cancelled by operator` as the error.
        """

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify the delivery_id against the target server's event store/logs — confirm you are querying the same instance
  2. If you only know the issue, retry via `issue: "owner/repo#N"` so the server resolves the latest stored event
  3. Check whether events were purged by retention and re-trigger fresh triage if the event is gone for good
  4. Confirm you are not mixing staging and production delivery ids

Example fix

// before: id copied from another environment
await retry({ delivery_id: 'staging-uuid-123' });
// after: resolve from the live event store
const evt = await api.getLatestEventForIssue('acme/widgets#42');
await retry({ delivery_id: evt.deliveryId });
Defensive patterns

Strategy: validation

Validate before calling

// Resolve the id from the target server's own event store before retrying
const evt = await api.getLatestEventForIssue('acme/widgets#42');
if (!evt) throw new Error('unknown delivery: resolve an existing deliveryId from this instance first');
await api.retry({ delivery_id: evt.deliveryId });

Type guard

function isNonEmptyString(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0;
}

Try / catch

try {
  await api.retry({ delivery_id: id });
} catch (err) {
  if (err.status === 404 && /unknown delivery/.test(err.message)) {
    logger.error('delivery not in this server\'s store — wrong instance or purged event', { id });
  } else throw err;
}

Prevention

When it happens

Trigger: POSTing to the retry endpoint with `delivery_id` that does not exist in the database — ids from a different environment (staging vs prod), events deleted by retention/cleanup, ids truncated or mangled by the client, or webhooks that failed before being persisted.

Common situations: Copy-pasting a delivery id from the wrong robomp instance; re-running an old script after the database was wiped; a load balancer sent the original webhook to a different instance than the one you're retrying against; storage backend switched (e.g. new DB file) losing prior events.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/4694c99e175b5134. Report an issue: GitHub.