Edit a Format mid-batch: which version do queued items use?

A bulk queue dispatches items over time. If you edit the Format while it runs, later items can run the new package. Here is how to tell from the receipts.

4 min readSume
All posts

Do queued bulk items run the Format version from when I submitted?

Not necessarily. A bulk queue does not run all its items at once. With concurrency set between 1 and 16, it starts that many child runs and dispatches the rest as slots free up. Each child is created through the same path as a single run, and that path resolves the Format and snapshots its package when the child starts, not when you created the queue.

The queue itself does record a format.version when it is created. That number describes the queue, not every child. If you edit the Format while a 100-item queue is half done, the first items ran the old package and the later ones can run the new one.

How do I see which version each item actually ran?

Read each child run's receipt. Every run receipt carries format.version, the version that ran, and later edits never rewrite it. Fetch the queue to get each item's run_id, then fetch the run. Items that failed to start have run_id: null and no receipt, so skip them.

A spread of versions across one queue is the signal that the Format changed under it. Comparing the format.version of item 0 with the last item is enough to catch it.

import os, requests
API = "https://api.sume.com/v1"
H = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}

def versions(run_ids):
    seen = {}
    for rid in run_ids:
        if rid is None:
            continue
        r = requests.get(f"{API}/format-runs/{rid}", headers=H, timeout=30)
        r.raise_for_status()
        v = r.json()["data"]["format"]["version"]
        seen.setdefault(v, []).append(rid)
    return seen

# run_ids = [item["run_id"] for item in queue["items"]]
# print({v: len(ids) for v, ids in versions(run_ids).items()})

What should I do instead of editing mid-batch?

The simplest rule is that a Format is frozen while a queue is in flight. Sume has no endpoint to list queues or cancel a queue, so you cannot pause one cleanly. The only brake is cancelling children one by one through POST /v1/format-runs/{id}/cancel.

  • Finish or cancel the batch before you PUT new contents.
  • Pass If-Match with the package_sha you last read, so a second editor gets 409 format_package_sha_mismatch rather than silently overwriting you.
  • Test a change on a copy of the Format first; the staging post in this series shows the second-slug method.
  • If versions did mix, re-run only the items from the old version, using new idempotency keys, since a replayed key with the same payload returns the old queue.

Sources

Related posts

More in Formats

All Formats posts

Written by Sume