Find missing CometAPI FLUX images by starting with the list of assets you expected to deliver. In DuckDB, left-join that list to the latest FLUX task observations and to receipts for verified files in your storage. Every expected asset gets a row, even if the submission record or a poll is missing. An image with a Ready task and no receipt can still need a download. CometAPI returns the temporary download URL in result.sample. Get a FLUX image result

Last reviewed: 2026-11-22 UTC (2026-11-23 in Asia/Shanghai).

Record the expected image before submitting the task

Create an asset version for each slot in the delivery plan, such as cover-v3. Include the version so a receipt from an older render cannot satisfy the slot. When CometAPI accepts an asynchronous FLUX.2 Pro request, save its top-level id against that version. The create path is /flux/v1/flux-2-pro and the status path is /flux/v1/get_result, both on api.cometapi.com. Configure COMETAPI_KEY through your runtime secret store for the worker’s bearer authentication. FLUX API quickstart

Keep the slot in the manifest if the application lacks a confirmed task ID. A timed-out create request or a failed local write can leave this field empty after the provider accepted work. Check the original attempt record before deciding to send a new create request. If you recover the task ID, link it to the same asset version and refresh the export. See the accepted-task recovery pattern in the CometAPI job worker walkthrough .

Snapshot the provider state and storage receipts

Export all three files for one run, using one provider account and one storage namespace. Take the exports from a consistent point in your workflow, such as pausing writes while capturing the snapshots, then run the audit against those fixed files. A poll arriving while you export can otherwise make a valid run appear incomplete. Use a restricted working directory because task IDs and storage keys identify application records.

For each accepted poll, check that the response id matches the stored task ID. Export the latest valid observation per task with its status and a boolean has_sample. Set that boolean when the status is Ready and result.sample is a nonempty string. Keep the full URL in the worker for transfer and include just the boolean in the snapshot. Keep the observation time in the run records so an old Ready row prompts a fresh lookup before download. FLUX result response schema

Compute a SHA-256 digest from the validated image bytes your worker will write. Once the write to the asset version’s key succeeds, save the task ID, object key, and that digest in a durable receipt. When exporting receipts for a handoff, read the bytes at the same key the recipient will use and compare their SHA-256 digest with the recorded digest. Export task_id and object_key only on a match. Omit missing, unreadable, and mismatched objects from receipts.ndjson so those assets stay in the worklist. Prevent writes to the handoff keys during verification and delivery. For the destination writing and file validation steps, see saving CometAPI images in Node.js .

To try the audit with DuckDB CLI 1.5, save the following newline-delimited JSON files in the same directory. The example uses synthetic task IDs and storage keys. Create manifest.ndjson with seven expected assets.

{"asset_version":"cover-v3","task_id":"job-cover"}
{"asset_version":"detail-v2","task_id":"job-detail"}
{"asset_version":"hero-v4","task_id":null}
{"asset_version":"side-v1","task_id":"job-side"}
{"asset_version":"size-v2","task_id":"job-size"}
{"asset_version":"swatch-v5","task_id":"job-swatch"}
{"asset_version":"top-v1","task_id":"job-top"}

Save the available status observations in polls.ndjson. The Ready record for job-swatch simulates a result whose download field is missing during validation.

{"task_id":"job-detail","status":"Ready","has_sample":true}
{"task_id":"job-side","status":"Pending","has_sample":false}
{"task_id":"job-size","status":"Error","has_sample":false}
{"task_id":"job-swatch","status":"Ready","has_sample":false}

Save the fixture’s verified receipt in receipts.ndjson. This record represents an object whose digest matched its durable receipt.

{"task_id":"job-cover","object_key":"catalog/cover-v3.png"}

Join the snapshots without dropping unlinked assets

Save this query as audit.sql. read_json reads the files in newline_delimited mode with named column types. The default parse-error setting stops on malformed input. Primary and unique keys limit the join to one row per asset version. Foreign keys stop the audit if an observation or receipt names a task outside the manifest. These checks apply to the loaded rows, so validate the original types and fields when your exporter produces the files. DuckDB JSON loading and DuckDB constraints

CREATE TEMP TABLE manifest (
    asset_version VARCHAR PRIMARY KEY CHECK (length(trim(asset_version)) > 0),
    task_id VARCHAR UNIQUE CHECK (length(trim(task_id)) > 0)
);

CREATE TEMP TABLE polls (
    task_id VARCHAR PRIMARY KEY REFERENCES manifest(task_id),
    status VARCHAR NOT NULL CHECK (length(trim(status)) > 0),
    has_sample BOOLEAN NOT NULL CHECK (status = 'Ready' OR NOT has_sample)
);

CREATE TEMP TABLE receipts (
    task_id VARCHAR PRIMARY KEY REFERENCES manifest(task_id),
    object_key VARCHAR UNIQUE NOT NULL CHECK (length(trim(object_key)) > 0)
);

INSERT INTO manifest
SELECT asset_version, task_id
FROM read_json('manifest.ndjson', format = 'newline_delimited',
               columns = {asset_version: 'VARCHAR', task_id: 'VARCHAR'});

INSERT INTO polls
SELECT task_id, status, has_sample
FROM read_json('polls.ndjson', format = 'newline_delimited',
               columns = {task_id: 'VARCHAR', status: 'VARCHAR', has_sample: 'BOOLEAN'});

INSERT INTO receipts
SELECT task_id, object_key
FROM read_json('receipts.ndjson', format = 'newline_delimited',
               columns = {task_id: 'VARCHAR', object_key: 'VARCHAR'});

SELECT manifest.asset_version, manifest.task_id,
       polls.status AS provider_status, receipts.object_key,
       CASE
           WHEN receipts.task_id IS NOT NULL THEN 'Stored'
           WHEN manifest.task_id IS NULL THEN 'Resolve submission'
           WHEN polls.status = 'Ready' AND polls.has_sample THEN 'Fetch existing image'
           WHEN polls.status = 'Ready' THEN 'Inspect ready result'
           WHEN polls.status IN ('Error', 'Failed', 'Failure', 'failed', 'failure',
                                 'Task not found', 'Request Moderated', 'Content Moderated')
               THEN 'Review terminal status'
           ELSE 'Poll task'
       END AS next_action
FROM manifest
LEFT JOIN polls ON manifest.task_id = polls.task_id
LEFT JOIN receipts ON manifest.task_id = receipts.task_id
ORDER BY manifest.asset_version;

The left joins preserve every manifest row. The status stays NULL when a task has no accepted observation. A verified receipt takes precedence because the point of the audit is to confirm delivery. If you retain several polls per task, select the most recent valid one in your exporter using its observation time and a deterministic tie-breaker. Passing the full polling log to this query triggers the duplicate key check. DuckDB join semantics

Run from the directory containing the four files. -bail stops execution before the report if an import fails. Check the exit status before using the output in a handoff.

duckdb -batch -bail -csv :memory: < audit.sql

Decide what to recover from the report

The sample audit produces seven rows. Review the next_action column alongside the observed provider status and the task ID.

Asset versionProvider statusNext actionWhat to check
cover-v3NULLStoredThe storage receipt links job-cover to catalog/cover-v3.png.
detail-v2ReadyFetch existing imagePoll job-detail for a current result and transfer the image.
hero-v4NULLResolve submissionRecover the task ID from the submission record or investigate the uncertain create.
side-v1PendingPoll taskContinue the worker’s bounded polling for job-side.
size-v2ErrorReview terminal statusRead the task error in the restricted run record before deciding whether to replace it.
swatch-v5ReadyInspect ready resultCheck the response contract and worker parsing for the missing sample.
top-v1NULLPoll taskLook up job-top and record the first valid observation.

When a fresh poll returns a usable result.sample, transfer it promptly. If the transfer fails, check the destination against the recorded digest if you have a receipt, then inspect the current task result. A temporary URL can stop working even though a worker previously observed Ready. For a documented terminal status such as Task not found or Content Moderated, stop polling and investigate the provider outcome before creating another task. Use the report as a worklist for your existing worker. FLUX status and result handling

The baseline ran on DuckDB 1.5.0. Appending a duplicate poll, adding a receipt for an unrelated task, and adding a malformed JSON line each produced a nonzero exit before the report. Empty poll and receipt files still produced seven asset rows. Add a second receipt for job-detail to simulate a successful digest check in the fixture. Its row should read Stored and show the new object key.

Test a same-key replacement in staging using the fixture’s cover row and poll snapshot. First verify the original image at catalog/cover-v3.png and confirm that cover-v3 reads Stored. Replace the object with a different PNG while retaining the original receipt and its digest. Export receipts again and rerun the audit. On the mismatch, the exporter should omit the job-cover receipt, leaving cover-v3 with a NULL object key and the action Poll task. Check the current status of the existing job-cover task before deciding how to recover the file.

Before a staging handoff, compare the report’s set of asset versions with the approved delivery list. Investigate an absent version in the plan export, and resolve each outstanding action before signing off. After recovering an image, repeat the digest check and run the audit against a fresh set of snapshots.

Sources checked

These published API and DuckDB 1.5 references were checked on November 22, 2026 UTC. They document the current provider contract and the SQL behavior used in the fixture.