Repository navigation
fix(metadata): record post-refresh stale IDs against the canonical item - #38
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 141d57db6a01b13394ac4fc6a95350fbe87031b5 and 1a43683. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR makes stale-ID follow-up persistence use the canonical content ID returned by merge/refresh: follow-up deletions and re-upserts are applied against the canonical ID when available, otherwise they fall back to the originally requested ID. ChangesStale ID Canonicalization
Sequence Diagram(s)sequenceDiagram
participant processInternal
participant mergeAndPersist
participant refreshFollowUpContentID
participant MetadataStore
processInternal->>mergeAndPersist: refresh/merge and persist
mergeAndPersist->>processInternal: return ProcessResult (may include canonical ContentID)
processInternal->>refreshFollowUpContentID: compute followUpContentID(req.ContentID, ProcessResult)
refreshFollowUpContentID->>processInternal: return followUpContentID
processInternal->>MetadataStore: delete/upsert stale provider-404 IDs using followUpContentID
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/metadata/service.go`:
- Around line 1219-1231: The stale-ID cleanup currently runs whenever
followUpContentID is set, which can drop existing stale rows when provider404s
wasn't populated (e.g., req.ContentID was empty and result.ContentID was
canonicalized); change the guard so you only delete existing stale IDs if you
also tracked provider404s availability: wrap the DeleteByContentID call and the
subsequent Upsert loop behind a condition that verifies provider404s was
populated (for example check that req.ContentID != "" or provider404s is
non-empty) before calling s.staleIDRepo.DeleteByContentID(ctx,
followUpContentID) and s.staleIDRepo.Upsert(...); keep using s.staleIDRepo,
followUpContentID, provider404s, req.ContentID and result.ContentID to locate
and implement the check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5f03c95b-df12-49be-9ca7-55fa7f708275
📥 Commits
Reviewing files that changed from the base of the PR and between 4c5691f and 141d57db6a01b13394ac4fc6a95350fbe87031b5.
📒 Files selected for processing (2)
internal/metadata/refresh_followup_test.gointernal/metadata/service.go
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) <[email protected]>
141d57d to
1a43683
Compare
…em (Silo-Server#38) 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) <[email protected]>
…em (#38) 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) <[email protected]>
…em (#38) 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) <[email protected]>
…em (#38) 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) <[email protected]>
Resolves 8 open Dependabot alerts in web/pnpm-lock.yaml (all dev-only transitive dependencies) by pinning patched versions through the existing pnpm.overrides mechanism: - undici 7.24.7 -> 7.28.0 (via jsdom; alerts #43-#49, incl. 2 high: TLS cert validation bypass & cross-origin routing via SOCKS5 ProxyAgent) - js-yaml 4.1.1 -> 4.2.0 (via @eslint/eslintrc; alert #39, quadratic DoS) - @babel/core 7.29.0 -> 7.29.6 (via @vitejs/plugin-react; alert #38, arbitrary file read via sourceMappingURL) No vulnerable versions remain in the lockfile. Web build and lint pass; the only failing tests (ServerStorageStep ResizeObserver) are pre-existing on main and unrelated to these bumps. Co-authored-by: Claude Opus 4.8 <[email protected]>
…lo-Server#225) Resolves 8 open Dependabot alerts in web/pnpm-lock.yaml (all dev-only transitive dependencies) by pinning patched versions through the existing pnpm.overrides mechanism: - undici 7.24.7 -> 7.28.0 (via jsdom; alerts Silo-Server#43-Silo-Server#49, incl. 2 high: TLS cert validation bypass & cross-origin routing via SOCKS5 ProxyAgent) - js-yaml 4.1.1 -> 4.2.0 (via @eslint/eslintrc; alert Silo-Server#39, quadratic DoS) - @babel/core 7.29.0 -> 7.29.6 (via @vitejs/plugin-react; alert Silo-Server#38, arbitrary file read via sourceMappingURL) No vulnerable versions remain in the lockfile. Web build and lint pass; the only failing tests (ServerStorageStep ResizeObserver) are pre-existing on main and unrelated to these bumps. Co-authored-by: Claude Opus 4.8 <[email protected]>
Problem
processInternalcleared and re-recorded stale provider IDs againstreq.ContentIDaftermergeAndPersist. ButmergeAndPersistcan canonicalize the item into an existing one (provider-ID dedup), deletingreq.ContentIDand returning a differentresult.ContentID. In that case the post-mergeDeleteByContentID/Upserttargeted the now-deleted source: the upsert hit thestale_media_idscontent_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.Approach
Target the canonical ID (
result.ContentID, falling back toreq.ContentID) for the stale-ID follow-up via a smallrefreshFollowUpContentIDhelper — matching what the adjacent refresh-debt sync already uses (result.ContentID).Risks / follow-up
Low. When no canonicalization occurs,
result.ContentID == req.ContentIDand behavior is unchanged. This is a pre-existing caller-side issue surfaced during review of the stale-ID FK-violation fix (#37); it addresses the root cause of that race.Verification
go test ./internal/metadata/andgo vet ./internal/metadata/pass. The id-selection helper is unit-tested (nil / empty / blank / canonicalized). Note: the end-to-end wiring inprocessInternalis not covered by a test — the repo has no DB integration harness for that path.AI-use disclosure
Implemented with Claude Code (Opus 4.8), TDD, surfaced by a multi-agent review.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests