processInternal cleared and re-recorded stale provider IDs against
req.ContentID after mergeAndPersist. But mergeAndPersist can canonicalize
the item into an existing one (provider-ID dedup), deleting req.ContentID
and returning a different result.ContentID. In that case the post-merge
DeleteByContentID/Upsert targeted the now-deleted source: the upsert hit
the stale_media_ids content_id foreign key and the still-404ing providers
were never recorded on the surviving canonical item — so the same providers
get re-attempted (and re-404) on every subsequent refresh.
Target the canonical ID (result.ContentID, falling back to req.ContentID)
for the stale-ID follow-up via refreshFollowUpContentID, matching what the
adjacent refresh-debt sync already uses. The block stays guarded on
provider404s != nil (allocated only when req.ContentID was set) so a
content-id-less refresh that canonicalizes into an existing item does not
clear that item's stale rows without re-recording any. Unit-tested for the
nil/empty/canonicalized cases.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>