Skip to content

Add batch_id to explode parameters - #451

Merged
const-cloudinary merged 1 commit into
masterfrom
feature/explode-batch-id
Aug 27, 2026
Merged

Add batch_id to explode parameters#451
const-cloudinary merged 1 commit into
masterfrom
feature/explode-batch-id

Conversation

@const-cloudinary

Copy link
Copy Markdown
Member

Problem

uploader.explode builds its params inline and does not serialize batch_id, so a client-supplied value never reaches the wire:

uploader.explode("doc", page="all", format="jpg", batch_id="mybatch")
# -> {"status": "processing", "batch_id": "95e726aa…47245a"}   # server-minted, not ours

This matters because batch_id is what makes the completion notification pollable. explode is unconditionally async — it always enqueues a job and returns {"status": "processing", …} — so polling is the only way to observe completion.

Why the response batch_id isn't a substitute

The response and the notification payload both echo a batch_id even when the client sends none, but that value is not a poll partition key. The poll destination reads the key from ThreadContext, which is populated only from a client-supplied value; the server-minted fallback feeds the response body and payload via a different path. With no client value the notification is enqueued unpartitioned and cannot be polled.

Verification

Live against a real product environment, with a poll://* / explode trigger in place.

Before — three attempts, including one with notification_url='poll://*' passed explicitly, all timed out with an empty buffer despite the job succeeding (3 derived pages produced):

$ cld uploader explode explode_probe page=all format=jpg
{"status": "processing", "batch_id": "95e726aa…47245a"}
$ cld notifications poll --batch-id 95e726aa…47245a --timeout 40
error: Timed out after 40s with 0 event(s) received.

After:

$ cld uploader explode explode_probe page=all format=jpg batch_id=fixprobe777
{"status": "processing", "batch_id": "fixprobe777"}     # our value, echoed back
$ cld notifications poll --batch-id fixprobe777 --timeout 60
explode
Received 1 event(s).

upload --wait on the same cloud succeeded throughout, confirming the poll transport itself was healthy and the gap was specific to explode.

Tests

Adds test_explode_parameters — there was no explode coverage previously. It asserts public_id, format, notification_url and batch_id all reach the request params, and fails with KeyError: 'batch_id' without this change.

Only batch_id is added: the server ignores async on this endpoint since explode is always asynchronous.

🤖 Generated with Claude Code

`explode` built its params inline and did not serialize `batch_id`, so a
client-supplied value never reached the wire. The server accepts it on this
endpoint (`before_action :capture_notification_batch_id` covers every
UploadController action) and needs it to partition the completion notification
into a pollable batch: the poll destination reads the key from ThreadContext,
which is populated only from a client value. Without one the notification is
enqueued unpartitioned and cannot be polled, even though the response and the
payload both echo a server-minted `batch_id`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@const-cloudinary
const-cloudinary merged commit 36f6a18 into master Aug 27, 2026
14 of 16 checks passed
@const-cloudinary
const-cloudinary deleted the feature/explode-batch-id branch August 27, 2026 11:59
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.

1 participant