BUG: Thumbnail failure silently overrides proxy failure — flips asset to ready even when proxy is absent #87
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
In
services/worker/src/workers/thumbnail.js, thecatchblock unconditionally sets the assetstatus = 'ready'when a thumbnail job fails:The comment correctly describes the happy-failure case: proxy succeeded, thumbnail failed → mark ready so the asset isn't stuck in
processing. However, when the proxy job also fails, the proxy worker setsstatus = 'error'. If the thumbnail job was already queued and runs after the proxy fails (BullMQ delivers queued jobs regardless), the thumbnail job fails to download from S3 (there is no proxy file), then itscatchblock flips the asset status from'error'back to'ready'— even though no proxy and no thumbnail exist.Sequence that reproduces the bug:
status = 'processing'status = 'error'await thumbnailQueue.add('generate', ...)comes afterawait uploadToS3(...)in proxy.js). So the thumbnail job is only queued if the proxy upload succeeds.Revised assessment: The sequence is safe in the normal case. However, there is a scenario where
proxy_s3_keyandthumbnail_s3_keyare already set (from a prior successful run), then a re-queued thumbnail job fails for an asset that was later set to'error'by a different pathway (e.g., operator re-ran a proxy job on a corrupted re-upload). In that case, the thumbnailcatchwould silently flip'error'→'ready'.Also: If someone manually enqueues a thumbnail job for an asset that has no proxy (e.g., via the API or a future admin tool), the download will 404, the
catchwill setstatus = 'ready', and the asset appears ready with no proxy and no thumbnail.Suggested fix: In the thumbnail
catchblock, only setstatus = 'ready'when the current status is'processing'(i.e., don't silently override'error'):