audit-g4: status-enum miss batch #52
Reference in New Issue
Block a user
Delete Branch "dev"
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?
Summary
Group 4 of the 2026-06-02 multi-system drift audit. Five extension-miss findings where a status value was added on one side but a downstream consumer didn't pick it up — each had a real or latent operator-impacting consequence.
download_service._phase3_persistnow branches onImportResult.statusfor'failed'and'refreshed'. For'failed'(today only: archive probe crash/timeout from_import_archive), the source file is unlinked so the filesystem scanner doesn't re-import and re-crash on the same archive forever.'refreshed'is currently unreachable from the download path (nodeep=True) but the importer's contract documents it; treat asattached.Backfill auto-complete is now correctly gated. Was:
if return_code == 0 and files_downloaded == 0: backfill_runs_remaining = 0.VALIDATION_FAILEDexits the subprocess withreturncode=0andfiles_downloaded=0when every file was quarantined, matching the predicate exactly — zeroing the operator's armed backfill budget on the first quarantine run. Now requiresdl_result.success and error_type is Noneso only genuinely-empty successful runs drain the counter.attach_in_placearchive dispatch threadsartist/source_rowthrough_import_archive, archive-member_import_mediacalls, and_supersede. The filesystem-import path still uses bare_import_archive(source)and falls back to_resolve_artistpath-walk. The download path now bindsImageProvenanceto the explicit subscriptionSourceinstead of rediscovering by(artist_id, platform)— fixes the dispatch asymmetry the audit flagged.Three FE handlers now recognize
status:'deferred'from/api/sources/<id>/check:SubscriptionsTab.onCheckwas toasting "event #undefined" because it assumeddownload_event_idwas always presentSubscriptionsTab.checkAllwas counting deferred sources as queued, inflating the success tallyDownloadEventRow.onRetrywas toasting "re-queued" when nothing wasDownloadsTab.onRetryAllwhich already had it.celery_signals._queue_formapsbackup/admin/library_auditprefixes to'maintenance'(matchingtask_routes). Was returning'default'for those rows, so per-queue dashboard filters and the per-queue threshold overrides added in G3 silently missed them. The function comment said "keep in sync with task_routes" — the audit caught the drift.Test Plan
errorAND the archive file is removed from disk (won't get re-imported on the next scan)backfill_runs_remaining=3), trigger a run that quarantines every downloaded file (VALIDATION_FAILED) — confirm the counter decrements to 2 instead of zeroingImageProvenancerows linked to the subscription Source (not a freshly-derived one)N queued, M deferred (cooldown)TaskRun.queueis'maintenance'not'default'Audit reference
Closes Group 4 of plan task
Scribe #551. Group 5 (architectural debt — centroid two-sources-of-truth, ErrorType in FailingSourcesCard, hardcoded platform tuple, modal route-leak, race-poisoning, Fernet key safety, fandom cache invalidation, dead backfill_thumbnails Beat entry, cleanup cluster) is the last group.🤖 Generated with Claude Code
Five extension-miss findings from the 2026-06-02 audit, where a status value was added on one side but a downstream consumer didn't pick it up. - download_service._phase3_persist: explicit branches for ImportResult.status in ('failed','refreshed'). For 'failed' (archive probe crash from _import_archive), unlink the source file so the filesystem scanner doesn't re-import and re-crash on the same archive forever. 'refreshed' is currently unreachable from the download path (no deep=True) but matches the importer's documented contract; treat as 'attached'. - gallery-dl backfill auto-complete now gates on dl_result.success + no error_type, not just return_code==0 + files_downloaded==0. VALIDATION_FAILED exits the subprocess with returncode=0 and files_downloaded=0 when every file was quarantined, matching the prior predicate exactly and zeroing the operator's armed backfill budget on the FIRST quarantine run instead of decrementing. - attach_in_place archive dispatch now threads artist + source_row through _import_archive (and _import_media for archive members) and _supersede. The path-walk fallback (_resolve_artist) is still used by filesystem-import; the download path now binds ImageProvenance to the explicit subscription Source instead of rediscovering by (artist_id, platform). - Three FE handlers now recognize status:'deferred' from /api/sources/<id>/check: SubscriptionsTab.onCheck (was toasting "event #undefined"), SubscriptionsTab.checkAll (was counting deferred as queued), DownloadEventRow.onRetry (was saying "re-queued" when nothing was). Pattern matches DownloadsTab.onRetryAll which already had it. - celery_signals._queue_for now maps backup/admin/library_audit prefixes to 'maintenance' (matching task_routes). TaskRun.queue was returning 'default' for those rows, so per-queue dashboard filters and per-queue threshold overrides (added in G3) silently missed them.