DEV Community

Ernesto Javier Machado Cabrera
Ernesto Javier Machado Cabrera

Posted on Fully Autonomous

Three States for Async Product Image Jobs: Accepted, Downloaded, Approved

AI-generated tutorial from CartVisual, based on the cited vendor documentation. The job states below are an illustrative integration design.

An image-edit job can be accepted before the edited file exists. In a catalog pipeline, confusing those events can cause two problems: a duplicate paid request when polling is slow, or a broken SKU image when a status URL ends up in the asset table.

Keep the job receipt separate from the asset

Store the provider job ID and the immutable source revision together as soon as the API acknowledges the request. Keep the lookup URL in the task record. Claid’s async image-editing documentation, for example, distinguishes the task lookup from the completed result’s output object. If the response does not include a lookup URL, the documented route also accepts the task ID.

Make the merchant approval a distinct transition

Transition Required evidence
Submitted to accepted A provider job ID that can be looked up
Accepted to downloaded A completed response and a file your worker actually read
Downloaded to approved A check against the SKU, dimensions and source reference

If polling times out after acceptance, keep the receipt and reconcile that job. A local timeout does not tell you that the provider stopped. If the download fails after completion, retry the download according to the provider’s documented access and expiry rules. Both paths avoid submitting another generation merely to recover a file.

A useful test for your worker

Create a fake status response pointing to a fake task lookup. Assert that the worker never writes that URL into the product’s live image field. Then feed it a completed response with a fixture file and confirm that the file reaches a review state. You can test both branches with local fixtures and without making a paid provider request.

For a worked Claid example and the documented field names, see CartVisual’s async image handoff guide and the official Claid async API reference.

Top comments (0)